From 715bec40067b7770004a55cd66f2f6b90dae4c37 Mon Sep 17 00:00:00 2001 From: Sarah Witt Date: Wed, 26 Jun 2024 10:56:31 -0400 Subject: [PATCH] add try block --- .../datadog/publishers/DatadogQueuePublisher.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/datadog/jenkins/plugins/datadog/publishers/DatadogQueuePublisher.java b/src/main/java/org/datadog/jenkins/plugins/datadog/publishers/DatadogQueuePublisher.java index baa8da61..8db502f0 100644 --- a/src/main/java/org/datadog/jenkins/plugins/datadog/publishers/DatadogQueuePublisher.java +++ b/src/main/java/org/datadog/jenkins/plugins/datadog/publishers/DatadogQueuePublisher.java @@ -147,11 +147,16 @@ private static String getJobName(Task task) { WorkflowJob workflowJob = (WorkflowJob) task; return workflowJob.getFullName(); } - if (task != null) { - logger.info(String.format("Unknown job found: %s, %s", task.getDisplayName(), task.getUrl())); - } else { - logger.info(String.format("Null task found")); + try { + if (task != null) { + logger.info(String.format("Unknown job found: %s, %s", task.getDisplayName(), task.getUrl())); + } else { + logger.info("Null task found"); + } + } + catch (Exception e) { + logger.info("Failed to collect unknown job name"); } return "unknown"; }