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

Fix form fields for active choices parameters when triggering builds via the parameterized trigger plugin

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I recently discovered that jobs which contain parameter types supported by the Active Choices plugin don't get rendered correctly when using the parameterized trigger plugin.

      More specifically, when accessing the <JOB_URL>/parambuild/ URL for a particular job form elements provided by Active Choices parameters are rendered as plain-text parameters instead of their correct types. For example, choice parameters with drop down lists appear as text entry fields with no drop-down list at all.

        Attachments

          Issue Links

            Activity

            Hide
            leedega Kevin Phillips added a comment -

            I attached some screen shots illustrating the problem. A simple choice parameter with a list of choices generated by a groovy script. When using the /build URL for the job, the choices are rendered correctly. When using the /parambuild URL they are not. When the parameter type is 'active choices parameter' it appears as though the Groovy script does get executed but only the first choice from the list appears in the text entry field. When the parameter type is 'active choices reactive parameter' the form element is still rendered as a text entry field but there is no default value provided.

            Show
            leedega Kevin Phillips added a comment - I attached some screen shots illustrating the problem. A simple choice parameter with a list of choices generated by a groovy script. When using the /build URL for the job, the choices are rendered correctly. When using the /parambuild URL they are not. When the parameter type is 'active choices parameter' it appears as though the Groovy script does get executed but only the first choice from the list appears in the text entry field. When the parameter type is 'active choices reactive parameter' the form element is still rendered as a text entry field but there is no default value provided.
            Hide
            dumam Bartosz Nowak added a comment - - edited

            I got similar behavior with Extensible Choice Parameter v1.6.0 and Pipeline Build Step Plugin 2.9. It looks like groovy script is executed after trigger and thats why builds are unable to find this prams. When i execute it manually everything is working as suppose to.  

             

            Passed Params from triggering job: (missing SELECTED_RESOURCE_LABEL and SELECTED_BUILD)

             

            Error Log:

             

            Started by timer Obtained from -------------- Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] End of Pipeline groovy.lang.MissingPropertyException: No such property: SELECTED_RESOURCE_LABEL for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:270) at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:289) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:293) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:269) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29) at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) at WorkflowScript.run(WorkflowScript:56) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(ModelInterpreter.groovy:60) at WorkflowScript.run(WorkflowScript:1) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74) at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66) at sun.reflect.GeneratedMethodAccessor314.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:347) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Finished: FAILURE
            

             

             

            How it should look like:

             

            Triggered Pipeline Params

             

            parameters { 
            extendedChoice name: 'SELECTED_RESOURCE_LABEL', bindings: '', description: 'Select test device from accessible resources', groovyClasspath: '', multiSelectDelimiter: ',', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_SINGLE_SELECT', visibleItemCount: 5, groovyScript: ''' import org.jenkins.plugins.lockableresources.LockableResourcesManager return new ArrayList<String>(LockableResourcesManager.get().getAllLabels());'''
            extendedChoice name: 'SELECTED_BUILD', description: 'Job from rpms are taken', type: 'PT_SINGLE_SELECT', bindings: '', groovyClasspath: '', multiSelectDelimiter: ',', quoteValue: false, saveJSONParameterToFile: false, visibleItemCount: 5, groovyScript: ''' import jenkins.* import jenkins.model.* import hudson.* import hudson.model.* def projList = Jenkins.instance.getAllItems(AbstractItem.class).name projList.removeAll { it.contains("label=") }; projList.removeAll { !it.contains("build") }; return projList;'''
            booleanParam name: 'FLASH', defaultValue: false, description: "Re-flash device with clean image"
            booleanParam name: 'RUN_TESTS', defaultValue: false, description: "Disable tests for projects which don't has any tests specified yet"
            booleanParam name: 'INSTALL_RPMS', defaultValue: true, description: "Allows you to bypass the installation process"
            }
            

             

            Triggering Pipeline Prams and Steps

            environment { TRIG_PROJECT_NAME = "build" }
             
            parameters { 
            booleanParam name: 'FLASH', defaultValue: false, description: "Re-flash device with clean image" 
            booleanParam name: 'INSTALL_RPMS', defaultValue: true, description: "Allows you to bypass the installation process" 
            booleanParam name: 'RUN_TESTS', defaultValue: false, description: "Disable tests for projects which don't has any tests specified yet" 
            }
            agent none triggers { upstream threshold: hudson.model.Result.SUCCESS, upstreamProjects: '${TRIG_PROJECT_NAME}' } 
            stages { 
            stage('run job') { 
            steps { build job: 'test_ad_hoc', 
            parameters: [ 
            extendedChoice(name: 'SELECTED_RESOURCE_LABEL', value: 'device'), 
            extendedChoice(name: 'SELECTED_BUILD', value: "${TRIG_PROJECT_NAME}"), 
            booleanParam(name: 'FLASH', value: "${FLASH}"), 
            booleanParam(name: 'RUN_TESTS', value: "${RUN_TESTS}"), 
            booleanParam(name: 'INSTALL_RPMS', value: "${INSTALL_RPMS}") ] 
            } 
            } 
            }
             
            

             

             

             

            Show
            dumam Bartosz Nowak added a comment - - edited I got similar behavior with Extensible Choice Parameter v1.6.0 and Pipeline Build Step Plugin 2.9. It looks like groovy script is executed after trigger and thats why builds are unable to find this prams. When i execute it manually everything is working as suppose to.     Passed Params from triggering job: (missing SELECTED_RESOURCE_LABEL and SELECTED_BUILD)   Error Log:   Started by timer Obtained from -------------- Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] End of Pipeline groovy.lang.MissingPropertyException: No such property: SELECTED_RESOURCE_LABEL for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:270) at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:289) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:293) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:269) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29) at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) at WorkflowScript.run(WorkflowScript:56) at org.jenkinsci.plugins.pipeline.modeldefinition.ModelInterpreter.call(ModelInterpreter.groovy:60) at WorkflowScript.run(WorkflowScript:1) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74) at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66) at sun.reflect.GeneratedMethodAccessor314.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:347) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) Finished: FAILURE     How it should look like:   Triggered Pipeline Params   parameters { extendedChoice name: 'SELECTED_RESOURCE_LABEL' , bindings: '', description: ' Select test device from accessible resources ', groovyClasspath: ' ', multiSelectDelimiter: ' , ', quoteValue: false , saveJSONParameterToFile: false , type: ' PT_SINGLE_SELECT ', visibleItemCount: 5, groovyScript: ' '' import org.jenkins.plugins.lockableresources.LockableResourcesManager return new ArrayList< String >(LockableResourcesManager.get().getAllLabels());' '' extendedChoice name: 'SELECTED_BUILD' , description: 'Job from rpms are taken' , type: 'PT_SINGLE_SELECT' , bindings: '', groovyClasspath: ' ', multiSelectDelimiter: ' , ', quoteValue: false , saveJSONParameterToFile: false , visibleItemCount: 5, groovyScript: ' '' import jenkins.* import jenkins.model.* import hudson.* import hudson.model.* def projList = Jenkins.instance.getAllItems(AbstractItem.class).name projList.removeAll { it.contains( "label=" ) }; projList.removeAll { !it.contains( "build" ) }; return projList;' '' booleanParam name: 'FLASH' , defaultValue: false , description: "Re-flash device with clean image" booleanParam name: 'RUN_TESTS' , defaultValue: false , description: "Disable tests for projects which don't has any tests specified yet" booleanParam name: 'INSTALL_RPMS' , defaultValue: true , description: "Allows you to bypass the installation process" }   Triggering Pipeline Prams and Steps environment { TRIG_PROJECT_NAME = "build" }   parameters { booleanParam name: 'FLASH' , defaultValue: false , description: "Re-flash device with clean image" booleanParam name: 'INSTALL_RPMS' , defaultValue: true , description: "Allows you to bypass the installation process" booleanParam name: 'RUN_TESTS' , defaultValue: false , description: "Disable tests for projects which don't has any tests specified yet" } agent none triggers { upstream threshold: hudson.model.Result.SUCCESS, upstreamProjects: '${TRIG_PROJECT_NAME}' } stages { stage( 'run job' ) { steps { build job: 'test_ad_hoc' , parameters: [ extendedChoice(name: 'SELECTED_RESOURCE_LABEL' , value: 'device' ), extendedChoice(name: 'SELECTED_BUILD' , value: "${TRIG_PROJECT_NAME}" ), booleanParam(name: 'FLASH' , value: "${FLASH}" ), booleanParam(name: 'RUN_TESTS' , value: "${RUN_TESTS}" ), booleanParam(name: 'INSTALL_RPMS' , value: "${INSTALL_RPMS}" ) ] } } }        

              People

              • Assignee:
                kinow Bruno P. Kinoshita
                Reporter:
                leedega Kevin Phillips
              • Votes:
                3 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: