Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-29476

The 'jenkinsProject' variable is not set in the binding after restarting Jenkins

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Component/s: active-choices-plugin
    • Labels:
      None
    • Environment:
      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
    • Similar Issues:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kinow Bruno P. Kinoshita
              Reporter:
              valdemon Waldek Kozba
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: