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

Active choices parameters not rendering after dsl generation

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 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)

    Description

      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.

      Attachments

        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

        Issue Links

          Activity

            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

            kinow 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.

            kinow 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.
            carek 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.

            carek 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

            kinow 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
            kinow 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.

            kinow 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.

            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

            kinow 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

            For convenience, the script used:

            job('JENKINS-42655') {
                parameters {
                  activeChoiceParam('States') {
                    description('Name of the State')
                    filterable() 
                    choiceType('SINGLE_SELECT')
                    groovyScript {
                      script('return ["Sao Paulo", "Rio de Janeiro"]')
                      fallbackScript('"Error in script"')
                    }
                  },
                  activeChoiceReactiveParam('Cities') {
                    description('Name of the State')
                    filterable() 
                    choiceType('SINGLE_SELECT')
                    referencedParameters('States')
                    groovyScript {
                      script('if (States.equals("Sao Paulo") { return ["Itu", "Araras"] } else { return ["Angra dos Reis"] }')
                      fallbackScript('"Error in script"')
                    }
                  }
              }
            }
            
            kinow Bruno P. Kinoshita added a comment - For convenience, the script used: job( 'JENKINS-42655' ) { parameters { activeChoiceParam( 'States' ) { description( 'Name of the State' ) filterable() choiceType( 'SINGLE_SELECT' ) groovyScript { script( ' return [ "Sao Paulo" , "Rio de Janeiro" ]' ) fallbackScript( ' "Error in script" ' ) } }, activeChoiceReactiveParam( 'Cities' ) { description( 'Name of the State' ) filterable() choiceType( 'SINGLE_SELECT' ) referencedParameters( 'States' ) groovyScript { script( ' if (States.equals( "Sao Paulo" ) { return [ "Itu" , "Araras" ] } else { return [ "Angra dos Reis" ] }' ) fallbackScript( ' "Error in script" ' ) } } } }

            What an exception generated by the script-security-plugin looks like:

            mar 13, 2017 10:23:55 PM org.biouno.unochoice.AbstractScriptableParameter eval
            SEVERE: Error executing script for dynamic parameter
            java.lang.RuntimeException: Failed to evaluate fallback script: script not yet approved for use
            	at org.biouno.unochoice.model.GroovyScript.eval(GroovyScript.java:178)
            	at org.biouno.unochoice.util.ScriptCallback.call(ScriptCallback.java:96)
            	at org.biouno.unochoice.AbstractScriptableParameter.eval(AbstractScriptableParameter.java:239)
            	at org.biouno.unochoice.AbstractScriptableParameter.getChoices(AbstractScriptableParameter.java:200)
            	at org.biouno.unochoice.AbstractCascadableParameter.getChoicesForUI(AbstractCascadableParameter.java:150)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:498)
            	at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:335)
            	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:175)
            	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:108)
            	at org.kohsuke.stapler.MetaClass$JavaScriptProxyMethodDispatcher.doDispatch(MetaClass.java:456)
            	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
            	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
            	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
            	at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:362)
            	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
            	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
            	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:813)
            	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
            	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
            	at org.kohsuke.stapler.Stapler.service(Stapler.java:199)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
            	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
            	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
            	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135)
            	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126)
            	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
            	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:80)
            	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
            	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
            	at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
            	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
            	at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
            	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
            	at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
            	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
            	at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
            	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
            	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
            	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
            	at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
            	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
            	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
            	at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
            	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
            	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
            	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
            	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
            	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
            	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
            	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
            	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
            	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
            	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
            	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
            	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
            	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553)
            	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
            	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
            	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
            	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
            	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
            	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
            	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
            	at org.eclipse.jetty.server.Server.handle(Server.java:499)
            	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
            	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
            	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
            	at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
            	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            	at java.lang.Thread.run(Thread.java:745)
            Caused by: org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedUsageException: script not yet approved for use
            	at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:459)
            	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:170)
            	at org.biouno.unochoice.model.GroovyScript.eval(GroovyScript.java:175)
            	... 73 more
            
            
            kinow Bruno P. Kinoshita added a comment - What an exception generated by the script-security-plugin looks like: mar 13, 2017 10:23:55 PM org.biouno.unochoice.AbstractScriptableParameter eval SEVERE: Error executing script for dynamic parameter java.lang.RuntimeException: Failed to evaluate fallback script: script not yet approved for use at org.biouno.unochoice.model.GroovyScript.eval(GroovyScript.java:178) at org.biouno.unochoice.util.ScriptCallback.call(ScriptCallback.java:96) at org.biouno.unochoice.AbstractScriptableParameter.eval(AbstractScriptableParameter.java:239) at org.biouno.unochoice.AbstractScriptableParameter.getChoices(AbstractScriptableParameter.java:200) at org.biouno.unochoice.AbstractCascadableParameter.getChoicesForUI(AbstractCascadableParameter.java:150) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:335) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:175) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:108) at org.kohsuke.stapler.MetaClass$JavaScriptProxyMethodDispatcher.doDispatch(MetaClass.java:456) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:362) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:813) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649) at org.kohsuke.stapler.Stapler.service(Stapler.java:199) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135) at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:80) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84) at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249) at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedUsageException: script not yet approved for use at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:459) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:170) at org.biouno.unochoice.model.GroovyScript.eval(GroovyScript.java:175) ... 73 more

            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.

            kinow 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.
            carek 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!

            carek 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!
            hhami93 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

             

            hhami93 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?

            prashanthbgoud 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 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!

             

            franksch77 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!  
            helenvturner 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.

            helenvturner 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

             

             

            franksch77 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    
            ninjagprules 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

            ninjagprules 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
            gopivalleru 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. 

             

            gopivalleru 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.   

            People

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

              Dates

                Created:
                Updated: