Status: Open (View Workflow)
Jenkins 1.637 and above
Jenkins 1.637 introduced a problem related to parameterized builds. This problem has impact in multiple situations, as I am going to describe next.
Jenkins 1.637 introduced the "OptionalJobProperty" class. Please see this commit: https://github.com/jenkinsci/jenkins/commit/53c86ec857a49609613ed1871a01830d51a89265
Follow the following steps:
- Create a new job "Job1"
- Activate the option "This build is parameterized"
- Don't add any parameter
- Save the job
- Get back to the job configuration
Previous to this version, you would see that Jenkins was "smart" enough to understand that it makes no sense to have a parameterized job without parameters, so it wouldn't save this option.
After this version, the "This build is parameterized" option is active (and actually saved to the config.xml file) without any parameter. See the attached image "1".
The config.xml file contains the following content.
<properties> <hudson.model.ParametersDefinitionProperty/> </properties>
Downstream job trigger
Follow these steps:
- Install the "Parameterized Trigger Plugin"
- Add a new job "Job0". Add a downstream job "Job1", and pass the current build parameters.
- Trigger "Job0", and wait for it to trigger "Job1"
- Before Jenkins 1.637, the job is triggered with no problems.
- After Jenkins 1.637, Job1 won't be triggered.
This appears in Console Output.
ERROR: Failed to build parameters to trigger project: Job1
This is not a major problem because there a workaround.
- is related to
JENKINS-46638 Null pointer exception saving a parameterized freestyle job with no parameters defined
- relates to
JENKINS-33201 Java JSON exception with an empty parametrized build.
JENKINS-37590 RuntimeException Error if you attempt to save a parameterized build with no parameters
jglick Any idea how to deal with this in OptionalJobProperty?
We would need to override ParametersDefinitionProperty.DescriptorImpl.newInstance to return null in case the super return value had parameterDefinitions.isEmpty().
That said, the NPE from ProjectSpecificParameterValuesActionTransform.getParameterDefinitionsMap seems like a bug in that plugin. Nowhere (that I can see) is it guaranteed that the parameter list is nonempty; the traditional UI just did not create that situation.
This could be seen as a problem of both Jenkins-core and the parameterized trigger plugin.
I am going to submit a pull request for Jenkins-core, and I will also submit a pull request to the parameterized trigger plugin, in order to increase the possibility of fixing the problem (ideally it would require to upgrade both Jenkins AND the Parameterized Trigger Plugin, but upgrading just one of them will solve part of the problem, which is better than nothing). I will treat the problem on the plugin side on another JIRA issue.