From: Kienan Stewart Date: Wed, 7 Jun 2023 15:01:05 +0000 (-0400) Subject: jjb: Fix crash when trying to launch a job that is not defined X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9ee19c2b8f8af895460c3cc132282a9f85ec27dd;p=lttng-ci.git jjb: Fix crash when trying to launch a job that is not defined Original error: ``` Launching job: baremetal_tests_kmaster_lmaster ERROR: Build step failed with exception java.lang.NullPointerException: Cannot invoke method getProperty() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:34) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at hudson.model.Job$getProperty$0.call(Unknown Source) at Script1$_run_closure8.doCall(Script1.groovy:273) ... ``` After applying this correction, a run with undefined jobs would look like this: ``` Launching job: baremetal_tests_kmaster_lmaster Failed to find job by name 'baremetal_tests_klinux-6.1.y_lmaster' Launching job: baremetal_tests_klinux-5.15.y_lmaster ... ``` Change-Id: Idedb693816c4928a5318397a724a6096dd544f7d --- diff --git a/scripts/system-tests/system-trigger.groovy b/scripts/system-tests/system-trigger.groovy index fd5b901..c4013da 100644 --- a/scripts/system-tests/system-trigger.groovy +++ b/scripts/system-tests/system-trigger.groovy @@ -269,6 +269,10 @@ def CraftJobName = { jobType, linuxBranch, lttngBranch -> def LaunchJob = { jobName, jobInfo -> def job = Hudson.instance.getJob(jobName) + if (job == null) { + println(String.format("Failed to find job by name '%s'", jobName)) + return null; + } def params = [] for (paramdef in job.getProperty(ParametersDefinitionProperty.class).getParameterDefinitions()) { // If there is a default value for this parameter, use it. Don't use empty @@ -451,7 +455,7 @@ while (ongoingJobs > 0) { // The isCancelled() method checks if the run was cancelled before // execution. We consider such run as being aborted. - if (jobBuild.isCancelled()) { + if (jobBuild == null || jobBuild.isCancelled()) { println("${jobName} was cancelled before launch.") isAborted = true; abortedRuns.add(jobName);