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

Active choices parameters not rendering after dsl generation

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • active-choices-plugin
    • None
    • Windows Server 2012 R2 64bit
      JDK8 u112
      Jenkins 2.49
      active choices plugin 1.5.2
      job dsl plugin 1.58
      Jenkins run directly
      no proxy
      no slave nodes
      Chrome browser 56.0.2924.87 (64-bit)

      I have just installed active-choices plugin and used it in conjunction with job dsl plugin.

      When I generate job with active choices plugin, fields do not render. Going into configuration and clicking save (without changing anything) fixes problem although it is frustrating bug because it needs to be done after each generation. Screens are attached.

      As you can see I am using  

      • 1 activeChoiceParam (single select)
      • 10 activeChoiceReactiveReferenceParam (formatted html)
      • 1 activeChoiceReactiveParam (checkbox)

      formatted html looks like this:

      return '<input name="value" value="${parameter}" class="setting-input" type="text" readonly>'

       

      I also found this issue - https://issues.jenkins-ci.org/browse/JENKINS-39760

      maybe it is related somehow.

        1. JENKINS-42655-2.2-config.xml
          3 kB
        2. JENKINS-42655-2.1-config.xml
          2 kB
        3. JENKINS-42655-config.xml
          2 kB
        4. JENKINS-42655-diff.png
          JENKINS-42655-diff.png
          365 kB
        5. after generation.jpg
          after generation.jpg
          22 kB
        6. after save.jpg
          after save.jpg
          76 kB

          [JENKINS-42655] Active choices parameters not rendering after dsl generation

          Piotr Tempes created issue -
          Piotr Tempes made changes -
          Description Original: I have just installed active-choices plugin and used it in conjunction with job dsl plugin.

          When I generate job with active choices plugin, fields do not render. Going into configuration and clicking save (without changing anything) fixes problem although it is frustrating bug because it needs to be done after each generation. Screens are attached.

          As you can see I am using  
           * 1 activeChoiceParam (single select)
           * 10 activeChoiceReactiveReferenceParam (formatted html)
           * 1 activeChoiceReactiveParam (checkbox)

          formatted html looks like this:

          return '<input name="value" value="$\{parameter}" class="setting-input" type="text" readonly>'
          New: I have just installed active-choices plugin and used it in conjunction with job dsl plugin.

          When I generate job with active choices plugin, fields do not render. Going into configuration and clicking save (without changing anything) fixes problem although it is frustrating bug because it needs to be done after each generation. Screens are attached.

          As you can see I am using  
           * 1 activeChoiceParam (single select)
           * 10 activeChoiceReactiveReferenceParam (formatted html)
           * 1 activeChoiceReactiveParam (checkbox)

          formatted html looks like this:

          return '<input name="value" value="$\{parameter}" class="setting-input" type="text" readonly>'

           

          I also found this issue - https://issues.jenkins-ci.org/browse/JENKINS-39760

          maybe it is related somehow.

          Hi carek

          Thanks for the detailed report. Triaging issues this weekend for the next development cycle. I'm also a Job DSL user, so it might make it easier for me to work on this issue

          Will investigate the problem in this next cycle, and hopefully submit a fix or update this ticket in the next days.

          Cheers
          Bruno

          Bruno P. Kinoshita added a comment - Hi carek Thanks for the detailed report. Triaging issues this weekend for the next development cycle. I'm also a Job DSL user, so it might make it easier for me to work on this issue Will investigate the problem in this next cycle, and hopefully submit a fix or update this ticket in the next days. Cheers Bruno

          Hopefully not related to JENKINS-39760 as you reported (thanks for providing detailed environment settings!!) 1.5.2. Will keep that in mind anyway.

          Bruno P. Kinoshita added a comment - Hopefully not related to JENKINS-39760 as you reported (thanks for providing detailed environment settings!!) 1.5.2. Will keep that in mind anyway.

          Piotr Tempes added a comment - - edited

          Would be great if you fix it (and performance issues in the other thread as well ;P). Thanks for an answer. It good to know you are on it

          Anyway I am writing to give you a little update... there is one more thing I noticed - not only resave makes the job to render correctly, but running the job seems to force it to rerender as well... So first run (on incorrectly rendered form) is executed incorrectly - not rendered parameters are missing, but after this run job form is ok so consecutive runs are fine.

          Piotr Tempes added a comment - - edited Would be great if you fix it (and performance issues in the other thread as well ;P). Thanks for an answer. It good to know you are on it Anyway I am writing to give you a little update... there is one more thing I noticed - not only resave makes the job to render correctly, but running the job seems to force it to rerender as well... So first run (on incorrectly rendered form) is executed incorrectly - not rendered parameters are missing, but after this run job form is ok so consecutive runs are fine.

          Very interesting! Bet it will be either extremely easy to fix it, or one of those bugs that requires a full stormy-rainy weekends here

          Thanks Piotr

          Bruno P. Kinoshita added a comment - Very interesting! Bet it will be either extremely easy to fix it, or one of those bugs that requires a full stormy-rainy weekends here Thanks Piotr

          Bruno P. Kinoshita added a comment - - edited

          TIL someone added support to Active Choices in Job DSL Plug-in (cc ioannis I don't believe we have links for that in our docs )

          https://github.com/jenkinsci/job-dsl-plugin/tree/master/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/parameter

          Note to self: update DSL when changing things in the plug-in, for backward compatibility.

          Bruno P. Kinoshita added a comment - - edited TIL someone added support to Active Choices in Job DSL Plug-in (cc ioannis I don't believe we have links for that in our docs ) https://github.com/jenkinsci/job-dsl-plugin/tree/master/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/parameter Note to self: update DSL when changing things in the plug-in, for backward compatibility.
          Bruno P. Kinoshita made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          Well, that was fun bug reproduced, I believe I know why that's happening. Not so complicated to fix... but no fast way to fix it. Here's the issue analysis (grab a coffee to read it).

          • Downloaded jenkins.war (2.32.3.war)
          • mkdir /tmp/123
          • JENKINS_HOME=/tmp/123 java -jar jenkins.war
          • Entered secret into form and submitted
          • Installed suggested plugins (boy that takes a while)
          • Created temp user
          • Installed (without restart) active-choices-plugin 1.5.3
          • Installed (without restart) job-dsl-plugin
          • Manually stopped Jenkins, and started it again with same command #3
          • Log in with user, all looking good
          • Created Freestyle job JENKINS-42655 (see attached config.xml)
          • Executed job, and found new job JENKINS-42655-1
          • Never opened the job configuration, clicked on the "Generated Items link to JENKINS-42655-1" to open in a new tab
          • Clicked on Build with Parameters
          • Looked at logs, and noticed the security-script-plugin exceptions
          • Went to "Manage Jenkins" / "In-process Script Approval" and approved scripts
          • Went back to the JENKINS-42655-1 build with parameters screen, and everything worked as expected

          Hummm. Issue more or less reproduced. Let's investigate more.

          • Restarted Jenkins again
          • Changed the JENKINS-42655 seed job configuration to use a different script
          • Copied the config.xml file to another location
          • Went to build with parameters, and now it was broken again
          • Saved the job manually
          • Copied the config.xml file to yet another location
          • Went to build with parameters, and now it worked as reported in this issue

          Now comes the interesting part. Looking at the diff. Attaching a screen shot so that others can have fun looking at it too. I installed Kompare as it has some cool features such as disabling diff for white spaces, blank lines, etc. The whole file changes as you save it. But if you ignore the number of white spaces... Then you can see that the Job DSL Plug-in is creating a <script> tag, as we used to do before 1.5 I think.

          Now we use the script-security-plugin. So we need to wrap that around the script-security-plugin's tags. Will report an issue for job-dsl-plugin, and will probably submit a pull request in the next days too. There's not much left we can change in the plug-in code for that carek, so I'm afraid you will have to:

          • keep saving the job
          • perhaps work on the fix for Job DSL if you feel like doing it (as you could probably be faster than me in submitting the PR)
          • use an older version of the active-choices-plugin that doesn't use security-script-plugin, though you could be bitten by other old bugs
          • write some script to replace the <script> tag and wrap it by the secureScript (doing what the pull request will do automatically later)

          Sorry for not being able to quickly provide any workaround, nor to cut a quick bugfix release.

          Cheers
          Bruno

          Bruno P. Kinoshita added a comment - Well, that was fun bug reproduced, I believe I know why that's happening. Not so complicated to fix... but no fast way to fix it. Here's the issue analysis (grab a coffee to read it). Downloaded jenkins.war (2.32.3.war) mkdir /tmp/123 JENKINS_HOME=/tmp/123 java -jar jenkins.war Entered secret into form and submitted Installed suggested plugins (boy that takes a while) Created temp user Installed (without restart) active-choices-plugin 1.5.3 Installed (without restart) job-dsl-plugin Manually stopped Jenkins, and started it again with same command #3 Log in with user, all looking good Created Freestyle job JENKINS-42655 (see attached config.xml) Executed job, and found new job JENKINS-42655 -1 Never opened the job configuration, clicked on the "Generated Items link to JENKINS-42655 -1" to open in a new tab Clicked on Build with Parameters Looked at logs, and noticed the security-script-plugin exceptions Went to "Manage Jenkins" / "In-process Script Approval" and approved scripts Went back to the JENKINS-42655 -1 build with parameters screen, and everything worked as expected Hummm. Issue more or less reproduced. Let's investigate more. Restarted Jenkins again Changed the JENKINS-42655 seed job configuration to use a different script Copied the config.xml file to another location Went to build with parameters, and now it was broken again Saved the job manually Copied the config.xml file to yet another location Went to build with parameters, and now it worked as reported in this issue Now comes the interesting part. Looking at the diff. Attaching a screen shot so that others can have fun looking at it too. I installed Kompare as it has some cool features such as disabling diff for white spaces, blank lines, etc. The whole file changes as you save it. But if you ignore the number of white spaces... Then you can see that the Job DSL Plug-in is creating a <script> tag, as we used to do before 1.5 I think. Now we use the script-security-plugin. So we need to wrap that around the script-security-plugin's tags. Will report an issue for job-dsl-plugin, and will probably submit a pull request in the next days too. There's not much left we can change in the plug-in code for that carek , so I'm afraid you will have to: keep saving the job perhaps work on the fix for Job DSL if you feel like doing it (as you could probably be faster than me in submitting the PR) use an older version of the active-choices-plugin that doesn't use security-script-plugin, though you could be bitten by other old bugs write some script to replace the <script> tag and wrap it by the secureScript (doing what the pull request will do automatically later) Sorry for not being able to quickly provide any workaround, nor to cut a quick bugfix release. Cheers Bruno
          Bruno P. Kinoshita made changes -
          Attachment New: JENKINS-42655-diff.png [ 36417 ]

            kinow Bruno P. Kinoshita
            carek Piotr Tempes
            Votes:
            5 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated: