Open timja opened 7 years ago
For anyone arriving here from a search: I found the following script (run in the script console) useful to identify the jobs that had null thresholds:
for (item in Jenkins.instance.allItems) { for (entry in item.properties) { def value try { value = entry.value; } catch (IllegalPropertyError) { continue; } if (value instanceof org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty) { for (trigger in value.triggers) { if (trigger instanceof jenkins.triggers.ReverseBuildTrigger) println(item.fullName + " " + trigger.threshold) } } } }
When setting up dependencies in a multibranch pipeline, I wrote
I had omitted the threshold parameter, assuming that it would default to SUCCESS (and I wasn't sure what to put in anyway due to
JENKINS-40304). The dependencies weren't working. I discovered this NPE in the logs:From what I can tell, omitting the threshold parameter is causing it to be set to null, leading to the null pointer exception. View Configuration in the GUI didn't reveal any problems, instead showing the threshold as success.
I don't know if there is any way in the Jenkins reflection system to prevent this, but it would be nice if it was possible for the pipeline script to give an error rather than silently inserting properties that cause exceptions, or else to pick a sensible default.
Originally reported by bmerry, imported from: Not passing threshold to ReverseBuildTrigger in Pipeline leads to NPEs