DSL for Choice Parameter

1,170 views
Skip to first unread message

jhavero

unread,
Oct 7, 2016, 11:58:41 AM10/7/16
to Jenkins Users
Does anyone know the DSL for the Choice parameter for a promote. See attached screenshot.

So far I have,

      promotion {
        name('promote')
        icon('gold-blue-e')
        // Promote
        conditions {
          manual(promote_users)
        }
Screen Shot 2016-10-07 at 8.54.03 AM.png

Victor Martinez

unread,
Oct 7, 2016, 12:03:38 PM10/7/16
to Jenkins Users
Hi there,


If you are talking about the jobdsl plugin:

What version of the jobdsl plugin do you use?

If you use 1.48+, if i recall correctly then you can use the autogenerated dsl documentation within your jenkins instance, further details:

https://github.com/jenkinsci/job-dsl-plugin/wiki/Automatically-Generated-DSL


Otherwise you might need to use the configure closure.

Cheers

jhavero

unread,
Oct 7, 2016, 1:04:45 PM10/7/16
to Jenkins Users
I am using jobdsl plugin 1.47. How does configure closure work.

jhavero

unread,
Oct 7, 2016, 1:48:27 PM10/7/16
to Jenkins Users
I have it close to work with the code below, however the list of choices - a, b, c - do not appear as options in the generated job. The parameter name 'myParameterName' and description 'my description' does appear correctly.

      promotion {
        name('Promote')
        icon('star-blue-e')
        //
        conditions {
          manual(promote_users, parameters {
            choiceParam('myParameterName', ['a', 'b', 'c'], 'my description')
          })

Victor Martinez

unread,
Oct 7, 2016, 6:17:28 PM10/7/16
to Jenkins Users
That DSL is implemented as part of the promotoon plugin itself:

Therefore you can use the choiceParam as suggested in the below link:

Besides of that, there is likely a bug in your snippet:

        conditions {
          manual(promote_users, parameters {
            choiceParam('myParameterName', ['a', 'b', 'c'], 'my description')
          })

Cheers
Reply all
Reply to author
Forward
0 new messages