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

Referenced Parameters Not Passed to Scriptler Scripts

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: active-choices-plugin
    • Labels:
      None
    • Environment:
      Jenkins 1.609.1, Active Choices 1.0, Scriptler 2.7
    • Similar Issues:

      Description

      To demonstrate the problem, create a Scriptler script as follows:

      println binding.variables
      first = binding.variables.get('First').tokenize(',')
      return first
      

      Name is unimportant. Then create a Jenkins job with three parameters:

      1. Active Choices Parameter, Name: First, Script: Groovy Script:

      return ['One','Two']
      

      Choice Type: Check Boxes

      2. Active Choices Reactive Parameter, Name: Second, Script: Groovy Script: same as the scriptler script:

      println binding.variables
      first = binding.variables.get('First').tokenize(',')
      return first
      

      Choice Type: Single Select, Referenced Parameters: First

      3. Active Choices Reactive Parameter, Name: Third, Script: Scripter Script, Script: (whatever you named the scriptler script above), Choice Type: Single Select, Referenced Parameters: First

      Save; run the script using Build With Parameters.

      Expected behavior: Checking checkboxes in First causes drop-down lists to be updated with checkbox items in Second and Third.

      Observed behavior: Checking checkboxes in First causes drop-down lists to be updated with checkbox items in Second but not in Third.

      Further confirmation: Verify binding.variables content in log. Switch Second and Third's script type and script contents and rerun.

        Attachments

          Activity

          Hide
          ayancey Amber Yancey added a comment -

          Is there any update on this issue yet? I have the same issue.

          Show
          ayancey Amber Yancey added a comment - Is there any update on this issue yet? I have the same issue.
          Hide
          etfloyd Edwin Floyd added a comment -

          Amber, I haven't seen any commits on the repository since the 1.0 release, other than the usual prep for next iteration. I do have what may be a fix. Unfortunately, I work in a high-security environment and can't even clone the repository, so can't try it out. That said, here's what I would try if I could:

          In org.biouno.unochoice.model.ScriptlerScript.java, eval() method, just after line 100, right before the return, insert a line to re-store the evaluated parameters in the original map so that the last two lines in the method are:

                  this.getParameters().putAll(evaledParameters);
                  return this.toGroovyScript().eval(evaledParameters);
          

          Maybe someone could try this out and provide a pull request for Bruno if it works?

          Show
          etfloyd Edwin Floyd added a comment - Amber, I haven't seen any commits on the repository since the 1.0 release, other than the usual prep for next iteration. I do have what may be a fix. Unfortunately, I work in a high-security environment and can't even clone the repository, so can't try it out. That said, here's what I would try if I could: In org.biouno.unochoice.model.ScriptlerScript.java, eval() method, just after line 100, right before the return, insert a line to re-store the evaluated parameters in the original map so that the last two lines in the method are: this .getParameters().putAll(evaledParameters); return this .toGroovyScript().eval(evaledParameters); Maybe someone could try this out and provide a pull request for Bruno if it works?
          Hide
          kinow Bruno P. Kinoshita added a comment -

          Hi Ember, Edwin

          I took a break after Mozilla Science Global Sprint with BioUno, but am now ready to push some commits again

          We have a testing instance on Amazon with Jenkins and the latest code. I will try to set up a sample job, and if I am able to reproduce to issue, then I'll try to create a unit test and apply Edwin's patch to see if that works.

          Feel free to bump this issue with some comment if I take too long to get back to you.

          Bruno

          Show
          kinow Bruno P. Kinoshita added a comment - Hi Ember, Edwin I took a break after Mozilla Science Global Sprint with BioUno, but am now ready to push some commits again We have a testing instance on Amazon with Jenkins and the latest code. I will try to set up a sample job, and if I am able to reproduce to issue, then I'll try to create a unit test and apply Edwin's patch to see if that works. Feel free to bump this issue with some comment if I take too long to get back to you. Bruno
          Hide
          kinow Bruno P. Kinoshita added a comment -

          Hello, I've changed the logic a little bit for Scriptler parameters.

          Before, the plug-in wasn't passing any variables to the binding context of the Scriptler parameter, unless you defined in the job configuration an input parameter.

          Now by default it adds every variable to the binding context, and *then* tries to expand each variable (i.e. convert things like $myVar to a value if existent). Will be included in the next release. Thanks, Bruno.

          Show
          kinow Bruno P. Kinoshita added a comment - Hello, I've changed the logic a little bit for Scriptler parameters. Before, the plug-in wasn't passing any variables to the binding context of the Scriptler parameter, unless you defined in the job configuration an input parameter. Now by default it adds every variable to the binding context, and * then * tries to expand each variable (i.e. convert things like $myVar to a value if existent). Will be included in the next release. Thanks, Bruno.
          Hide
          kinow Bruno P. Kinoshita added a comment -

          Committed using the wrong issue number, but here's the commit:

          Code changed in jenkins
          User: Bruno P. Kinoshita
          Path:
          src/main/java/org/biouno/unochoice/model/ScriptlerScript.java
          http://jenkins-ci.org/commit/active-choices-plugin/878f509d564a48671af629156ba4074ee0dd6fd8
          Log:
          [FIXED JENKINS-29055] Change logic to add parameters to the binding context of the Scriptler script. Then expand parameters used in the script too.

          Show
          kinow Bruno P. Kinoshita added a comment - Committed using the wrong issue number, but here's the commit: Code changed in jenkins User: Bruno P. Kinoshita Path: src/main/java/org/biouno/unochoice/model/ScriptlerScript.java http://jenkins-ci.org/commit/active-choices-plugin/878f509d564a48671af629156ba4074ee0dd6fd8 Log: [FIXED JENKINS-29055] Change logic to add parameters to the binding context of the Scriptler script. Then expand parameters used in the script too.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Bruno P. Kinoshita
          Path:
          src/test/java/org/biouno/unochoice/issue28785/TestIssue28785.java
          src/test/java/org/biouno/unochoice/issue28785/package-info.java
          http://jenkins-ci.org/commit/active-choices-plugin/457164bfbeea30905e45cbebc5371c15b92f652e
          Log:
          JENKINS-28785 Unit tests

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Bruno P. Kinoshita Path: src/test/java/org/biouno/unochoice/issue28785/TestIssue28785.java src/test/java/org/biouno/unochoice/issue28785/package-info.java http://jenkins-ci.org/commit/active-choices-plugin/457164bfbeea30905e45cbebc5371c15b92f652e Log: JENKINS-28785 Unit tests
          Hide
          kinow Bruno P. Kinoshita added a comment -

          Hi Edwin!

          Sorry, I have a useless memory, but looking at the comments, looks like we fixed it in https://github.com/jenkinsci/active-choices-plugin/commit/878f509d564a48671af629156ba4074ee0dd6fd8

          So I am marking this as Fixed. This fix was included in the 1.1 release.

          Sorry for the delay to close this issue and provide feedback on when it was released, and thanks again for your contribution!!!

          Show
          kinow Bruno P. Kinoshita added a comment - Hi Edwin! Sorry, I have a useless memory, but looking at the comments, looks like we fixed it in https://github.com/jenkinsci/active-choices-plugin/commit/878f509d564a48671af629156ba4074ee0dd6fd8 So I am marking this as Fixed. This fix was included in the 1.1 release. Sorry for the delay to close this issue and provide feedback on when it was released, and thanks again for your contribution!!!
          Hide
          kinow Bruno P. Kinoshita added a comment -

          Closing as it was fixed in 1.1

          Show
          kinow Bruno P. Kinoshita added a comment - Closing as it was fixed in 1.1

            People

            Assignee:
            kinow Bruno P. Kinoshita
            Reporter:
            etfloyd Edwin Floyd
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: