Skip to content

Instantly share code, notes, and snippets.

@jgraglia
Created July 11, 2017 10:38
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jgraglia/44a7443847cff6f0d87387a46c7bb82f to your computer and use it in GitHub Desktop.
Save jgraglia/44a7443847cff6f0d87387a46c7bb82f to your computer and use it in GitHub Desktop.
Extended Choice Plugin in Jenkins pipeline
// YOU HAVE TO :
// 1. install the Extended Choice Parameter Plugin : https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin
// 2. Allow the instanciation of ExtendedChoiceParameterDefinition in you script approval admin page https://myjenkins/scriptApproval/
List params = []
List props = []
// https://github.com/jenkinsci/extended-choice-parameter-plugin/blob/master/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java#L427
// https://issues.jenkins-ci.org/browse/JENKINS-34617
com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition test = new com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition(
"name",
"PT_CHECKBOX",
"VALUE, A, B",
null,//project name
null,
null,
null,
null,// bindings
null,
null, // propertykey
"VALUE, B", //default value
null,
null,
null,
null, //default bindings
null,
null,
null, //descriptionPropertyValue
null,
null,
null,
null,
null,
null,
null,// javascript file
null, // javascript
false, // save json param to file
false, // quote
2, // visible item count
"DESC",
","
)
params << test
props << parameters(params)
properties(props)
@AaronDMarasco-VSI
Copy link

Thanks!

@jgraglia
Copy link
Author

Be aware that this plugin is not fully compatible with BlueOcean.
You won't be able to start a job using a param of that type :=(

image

You can always go to Classic and start a job.
Note that the jobs are still displayed in BlueOcean, you just can't start one.

@Puneeth-n
Copy link

How do you use it as part of the declarative pipeline?

@Lemonsiny
Copy link

same question , How do you use it as part of the declarative pipeline?

@mgortzak
Copy link

mgortzak commented Jan 4, 2018

Thanks! Works like a charm :-).

@felyppers
Copy link

Man, thanks a lot! It did the trick! =D

@todor-kolev
Copy link

Thanks for sharing that! Do you have an example with multi-level json payload?

@NishanthiniRadhakrishnan

Same, How do you use it as part of the declarative pipeline?

@j14s
Copy link

j14s commented May 9, 2018

Bump for Declarative Pipeline

@steinmaerivoet
Copy link

Bump for Declarative Pipeline

@nalingarg2
Copy link

Thanks! this works great !

@jhagege
Copy link

jhagege commented Sep 2, 2018

Bump for declarative pipeline :)

@jhagege
Copy link

jhagege commented Sep 2, 2018

Looks great, does it support custom Groovy code ?
Thanks !

@starwarsfan
Copy link

How about Declarative Pipelines? Still a blocker...

@paulshestakov
Copy link

Bump for Declarative Pipeline

@rodrigc
Copy link

rodrigc commented Mar 4, 2019

I have a patch which allows extendedChoice() to be used in the parameters block of a declarative pipeline:

jenkinsci/extended-choice-parameter-plugin#25

@srinathgattugari
Copy link

@rodrigc i tried a lot and still struggling , could you please explain me bit more on this how did you do it.

@vikas027
Copy link

Hey @rodrigc, any pointers to deal with this issue?

@Manish-Kumar317
Copy link

same here....unable to use it in declarative pipeline

@ssc327
Copy link

ssc327 commented Mar 16, 2021

You can use is declarative pipeline now - jenkinsci/extended-choice-parameter-plugin#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment