-
Bug
-
Resolution: Fixed
-
Critical
-
None
-
Jenkins ver. 1.620 and 1.615;
Active Choices Plugin version 1.1;
Java 1.7.0_79-b14;
OS.version 3.2.0-4-amd64 Debian Wheezy
I've experienced a strange behavior, when working with the Active Choices Reactive Reference Parameter.
The use case was to set the parameter value to the actual Jenkins job name, as a fallback for missing referenced parameter value.
The Groovy code:
import hudson.model.* import jenkins.model.* def job = binding.jenkinsProject def artifactName = binding.variables.get("1_ARTIFACT") if (!artifactName) { artifactName = job.name } return "<input name=\"value\" value=\"${artifactName}\" class=\"setting-input\" type=\"text\">"
.. where the '1_ARTIFACT' is the referenced variable.
The above works as expected, when one creates a project and saves it in Jenkins UI.
It stops working though, after Jenkins restart.
After some investigation I've realized that the 'jenkinsProject' variable is missing in the binding after fresh Jenkins start (or restart).
When one goes then into the job configuration UI and presses the 'Save' button (no changes required), the above code starts working again, because the 'jenkinsProject' variable is injected into the binding.
It doesn't matter if the Groovy script is embedded in the parameter config or stored and referenced as Scriptler script, the bahavior is the same.
Apparently the 'jenkinsProject' variable is not being initialized for the org.biouno.unochoice.DynamicReferenceParameter during the Jenkins start.
- depends on
-
JENKINS-32149 Create random parameter name only once
-
- Closed
-
I have not been able to use any build environment parameters directly in the groovy script. They seem to be null. I agree that this is a high priority issue. It is very useful to have all of the build environment variables in the script binding context (for both groovy scripts and scriptlets)