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

            valdemon Waldek Kozba created issue -
            valdemon Waldek Kozba made changes -
            Field Original Value New Value
            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:
            {code:groovy}
            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\">"
            {code}
            .. 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.
            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 for the 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.
            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:
            {code:java}
            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\">"
            {code}
            .. 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.
            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 for the 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.
            valdemon Waldek Kozba made changes -
            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:
            {code:java}
            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\">"
            {code}
            .. 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.
            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 for the 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.
            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:
            {code:java}
            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\">"
            {code}
            .. 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.
            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.
            valdemon Waldek Kozba made changes -
            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:
            {code:java}
            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\">"
            {code}
            .. 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.
            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.
            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:
            {code:java}
            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\">"
            {code}
            .. 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.
            kinow Bruno P. Kinoshita made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            kinow Bruno P. Kinoshita made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            kinow Bruno P. Kinoshita made changes -
            Link This issue depends on JENKINS-32149 [ JENKINS-32149 ]
            kinow Bruno P. Kinoshita made changes -
            Attachment JENKINS-32149-02.png [ 31500 ]
            Attachment JENKINS-32149-01.png [ 31501 ]
            scm_issue_link SCM/JIRA link daemon made changes -
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Resolved [ 5 ]
            kinow Bruno P. Kinoshita made changes -
            Status Resolved [ 5 ] Closed [ 6 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 164352 ] JNJira + In-Review [ 209006 ]

              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: