[JIRA] (JENKINS-38995) Choice parameters cannot be used inside of Multibranch Pipelines

11 views
Skip to first unread message

tyler@monkeypox.org (JIRA)

unread,
Oct 14, 2016, 11:22:41 AM10/14/16
to jenkinsc...@googlegroups.com
R. Tyler Croy created an issue
 
Jenkins / Bug JENKINS-38995
Choice parameters cannot be used inside of Multibranch Pipelines
Issue Type: Bug Bug
Assignee: CloudBees Inc.
Components: pipeline
Created: 2016/Oct/14 3:20 PM
Priority: Minor Minor
Reporter: R. Tyler Croy

In a project I need parameters (with defaults) to execute property - imagine having a default to "debug" build parameter with the option for a user to select "release" build/deploys every now and again.

I can accomplish this with a "non-multibranch Pipeline" by using the Choice parameters when configuring the project, but when I use the properties step my Multibranch Pipeline cannot execute properly.

Given the following Jenkinsfile

properties([parameters([choice(choices: ['debug', 'release', 'dev'],
        description: '', name: 'buildType')]), pipelineTriggers([])])

node {
    echo buildType
   // echo "buildType is: ${buildType}"
}

This will result in the exception below:

Fetching origin...
Fetching changes from the remote Git repository
Checking out Revision 3471f057dff0ca3c958f7f522edb687b0f355988 (master)
[Pipeline] properties
[Pipeline] End of Pipeline
java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:384)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257)
	at org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable.instantiate(UninstantiatedDescribable.java:175)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:364)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(DescribableModel.java:453)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:357)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257)
	at org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable.instantiate(UninstantiatedDescribable.java:175)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:364)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(DescribableModel.java:453)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:357)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257)
	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:195)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:103)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
	at WorkflowScript.run(WorkflowScript:3)
	at ___cps.transform___(Native Method)
	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
	at sun.reflect.GeneratedMethodAccessor102.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.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
	at sun.reflect.GeneratedMethodAccessor103.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.ContinuationGroup.methodCall(ContinuationGroup.java:50)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
	at sun.reflect.GeneratedMethodAccessor102.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.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.access$000(CollectionLiteralBlock.java:31)
	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock.eval(CollectionLiteralBlock.java:26)
	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	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:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Finished: FAILURE

I should note, the project is not properly scanned for the parameter properties as the "Build Now" sidebar item does not change to "Build with Parameters".

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

jglick@cloudbees.com (JIRA)

unread,
Oct 14, 2016, 12:22:01 PM10/14/16
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Duplicate
 

See JENKINS-26143 for the syntax which is accepted.

Change By: Jesse Glick
Status: Open Resolved
Resolution: Duplicate

tyler@monkeypox.org (JIRA)

unread,
Oct 14, 2016, 12:48:02 PM10/14/16
to jenkinsc...@googlegroups.com
R. Tyler Croy commented on Bug JENKINS-38995
 
Re: Choice parameters cannot be used inside of Multibranch Pipelines

Jesse Glick, that ticket is for the choice parameter for the input step and doesn't clearly map to the properties step as far as I can tell? Perhaps that ticket title needs to be changed to something like "all choice parameters generated by the snippet generator are wrong?"

jglick@cloudbees.com (JIRA)

unread,
Oct 14, 2016, 1:21:02 PM10/14/16
to jenkinsc...@googlegroups.com

peter.niederlag@datenbetrieb.de (JIRA)

unread,
Feb 16, 2017, 5:46:02 AM2/16/17
to jenkinsc...@googlegroups.com

This problem is really anoying and filling quite a bunch of places on the net.

It seems that the array syntax of defining the choices is not supported and must be replaced by a string that is concatenated by \n. This snippet did the trick for me:

{{
properties([parameters([choice(choices: "debug\nrelease\ndev",


description: '', name: 'buildType')]), pipelineTriggers([])])
}}

peter.niederlag@datenbetrieb.de (JIRA)

unread,
Feb 16, 2017, 5:47:04 AM2/16/17
to jenkinsc...@googlegroups.com
Peter Niederlag edited a comment on Bug JENKINS-38995

peter.niederlag@datenbetrieb.de (JIRA)

unread,
Feb 16, 2017, 5:47:14 AM2/16/17
to jenkinsc...@googlegroups.com
Peter Niederlag edited a comment on Bug JENKINS-38995
This problem is really anoying and filling quite a bunch of places on the net.

It seems that the array syntax of defining the choices is not supported and must be replaced by a string that is concatenated by \n. This snippet did the trick for me:


{ { code:java}
properties([parameters([choice(choices: "debug\nrelease\ndev",
        description: '', name: 'buildType')]), pipelineTriggers([])])

{code
} }
Reply all
Reply to author
Forward
0 new messages