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. after generation.jpg
          after generation.jpg
          22 kB
        2. after save.jpg
          after save.jpg
          76 kB
        3. JENKINS-42655-2.1-config.xml
          2 kB
        4. JENKINS-42655-2.2-config.xml
          3 kB
        5. JENKINS-42655-config.xml
          2 kB
        6. JENKINS-42655-diff.png
          JENKINS-42655-diff.png
          365 kB

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

          Linking issue JENKINS-42710. That's that for tonight carek, moving to the next issues for 1.5.4 for now. Hopefully we will fix it soon.

          Bruno P. Kinoshita added a comment - Linking issue JENKINS-42710 . That's that for tonight carek , moving to the next issues for 1.5.4 for now. Hopefully we will fix it soon.

          Piotr Tempes added a comment -

          Wow that was fast. Thanks for comprehensive explanations. I hope fix will go out soon. I'll be looking forward to it. Thanks again for quick research!

          Piotr Tempes added a comment - Wow that was fast. Thanks for comprehensive explanations. I hope fix will go out soon. I'll be looking forward to it. Thanks again for quick research!

          Huseyin Hamilton added a comment - - edited

          Hi,

          Is this still an issue? Besides the temporary solutions, I can't see anything to suggest it's been resolved and I seem to still come across the problem:

          • Upload job via generated DSL job. 
          • Parameters aren't populated.
          • Click Configure for job, and immediately save. Job notes that manual changes have been made.
          • Parameters now are populated as expected by script.

          If the issues are caused by the approval of the fallback script, that is slightly annoying because I've actually disabled the script approval process completely anyway but still get the issue.

          Versions:
          Script Security Plugin - 1.48
          Active Choice Plugin - 2.1
          Jenkins Version - 2.138.3

           

          Huseyin Hamilton added a comment - - edited Hi, Is this still an issue? Besides the temporary solutions, I can't see anything to suggest it's been resolved and I seem to still come across the problem: Upload job via generated DSL job.  Parameters aren't populated. Click Configure for job, and immediately save. Job notes that manual changes have been made. Parameters now are populated as expected by script. If the issues are caused by the approval of the fallback script, that is slightly annoying because I've actually disabled the script approval process completely anyway but still get the issue. Versions : Script Security Plugin - 1.48 Active Choice Plugin - 2.1 Jenkins Version - 2.138.3  

          I see the same issue, any workaround for this?

          Prashanth Goud B added a comment - I see the same issue, any workaround for this?

          Same issue here:

          • Upload job via generated DSL job. 
          • Parameters aren't populated.
          • Click Configure for job, and immediately save. Job notes that manual changes have been made.
          • Parameters now are populated as expected by script.

          Versions:
          Script Security Plugin - 1.54
          Active Choices Plug-in - 2.1
          Jenkins Version - 2.176.1

          Any update?

          Romain DEQUIDT added a comment - Same issue here: Upload job via generated DSL job.  Parameters aren't populated. Click Configure for job, and immediately save. Job notes that manual changes have been made. Parameters now are populated as expected by script. Versions : Script Security Plugin - 1.54 Active Choices Plug-in - 2.1 Jenkins Version - 2.176.1 Any update?

          Same issue but I have a workaround:

          Execute the following in Jenkins script console after job creation:

          for (def job : Jenkins.instance.getItems())

          { job.doReload() }

           

          I also experiment with I post-build-groovy build-step do automate this after the auto creation of my jobs in a seed job (Jenkins DSL).

          It seems to work!

           

          Frank Schullerer added a comment - Same issue but I have a workaround: Execute the following in Jenkins script console after job creation: for (def job : Jenkins.instance.getItems()) { job.doReload() }   I also experiment with I post-build-groovy build-step do automate this after the auto creation of my jobs in a seed job (Jenkins DSL). It seems to work!  

          Helen added a comment - - edited

          franksch77 Could you please share more information about how you got this working as a post build step?

          I can execute the script in the script console and it works. However when I try to automate the process, it does not seem to work as expected.

          Helen added a comment - - edited franksch77 Could you please share more information about how you got this working as a post build step? I can execute the script in the script console and it works. However when I try to automate the process, it does not seem to work as expected.

          Hi Helen,

          I changed it later to a "Execute Shell" command and within I execute curl:

           

          curl -k --user '<MyJenkindID>:<MyJenkinsID_API-Token>' --data-urlencode "script=$(< /home/jenkins/reloadJobs.groovy)" https://127.0.0.1:9443/scriptText

          Nowadays, we have to authenticate to Jenkins via ID and API-Token. My  /home/jenkins/reloadJobs.groovy script on file system contains the Code:

           

          for (def job : Jenkins.instance.getItems())
          { job.doReload() }
          

           

           

          I hope it works for you too!

           

          Frank

           

           

          Frank Schullerer added a comment - Hi Helen, I changed it later to a "Execute Shell" command and within I execute curl:   curl -k --user '<MyJenkindID>:<MyJenkinsID_API-Token>' --data-urlencode "script=$(< /home/jenkins/reloadJobs.groovy)" https: //127.0.0.1:9443/scriptText Nowadays, we have to authenticate to Jenkins via ID and API-Token. My  /home/jenkins/reloadJobs.groovy script on file system contains the Code:   for (def job : Jenkins.instance.getItems()) { job.doReload() }     I hope it works for you too!   Frank    

          Marc Portabella added a comment - - edited

          I had the same issue. It was not rendered because the security hash is not been added with the jobdsl definition.

          I have added this code to add hash to approved scripts:

          import org.jenkinsci.plugins.scriptsecurity.scripts.*

          toApprove = ScriptApproval.get().getPendingScripts().collect()
          toApprove.each {pending -> ScriptApproval.get().approveScript(pending.getHash())}

           

          I hope this helps

          Marc Portabella added a comment - - edited I had the same issue. It was not rendered because the security hash is not been added with the jobdsl definition. I have added this code to add hash to approved scripts: import org.jenkinsci.plugins.scriptsecurity.scripts.* toApprove = ScriptApproval.get().getPendingScripts().collect() toApprove.each {pending -> ScriptApproval.get().approveScript(pending.getHash())}   I hope this helps

          Gopi added a comment -

          Reloading all jobs using scriptText works but it needs admin user's api token. We never had to create API token on any admin used except for this one single purpose. 

          This bug is active for over 5 years and there seems to be no better solution in using active choices param even when script security for Job DSL scripts is disabled. 

           

          Gopi added a comment - Reloading all jobs using scriptText works but it needs admin user's api token. We never had to create API token on any admin used except for this one single purpose.  This bug is active for over 5 years and there seems to be no better solution in using active choices param even when script security for Job DSL scripts is disabled.   

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

              Created:
              Updated: