Rao
Rao

Reputation: 21359

Dynamic Multiselect choice values in Jenkins

There is jenkins parameterized job.

And there are two properties defined

  1. Property1 of choice type (has different configurations)
  2. Property2 of Extended Choice with Multi select, Choose Source for Value as Groovy script(each configuration has list of different test suites). Referring to this jenkins plugin.

Would like to show the different list of values in Property2 based on the value selected for Property1.

Tried accessing Property1, $Property1, %Property1% in Groovy Script of Property2. But, does not seem to work.

Script looks something like below

if ($Property1 == 'configuration1') {
    return ['suite1','suite2', 'suite3']
} else if ($Property1 == 'configuration2') {
    return ['suite3', 'suite4']
} else if ($Property1 == 'configuration3') {
    return ['suite5', 'suite6']
}

Even returning simple list to Property2 also does not seem to work from Groovy Script like return ['suite1', 'suite2'] (just tried to show list of values without even checking condition). Am I missing something?

Upvotes: 2

Views: 3503

Answers (1)

Oleksandr Horobets
Oleksandr Horobets

Reputation: 1375

You can try Jenkins Active Choices plugin. The parameter options can be dynamically generated from a Groovy script and can respond to changes in other job parameters.

enter image description here

Upvotes: 2

Related Questions