Damien-Amen
Damien-Amen

Reputation: 7512

Jenkins Active Choices Parameter plugin not working as expected

I have a hidden parameter in Jenkins called platformType. I want to display choices based on the parameter platformType. I created the following groovy script but it doesn't work

if (platformType.equals("android")) {
  return ['7.0', '6.0']
} else (platformType.equals("ios")) {
  return ['10.0', '9.0']
}

Pls see the screenshot below enter image description here

Upvotes: 2

Views: 7178

Answers (2)

Rao
Rao

Reputation: 21389

Looks you are missing if in the else part.

It is supposed to be:

if ('android' == platformType) {
  return ['7.0', '6.0']
} else if ('ios' == platformType) {
  return ['10.0', '9.0']
} else return []

Upvotes: 0

daggett
daggett

Reputation: 28634

quite sure you did not specify the platformType as a parameter to platformVersion or you have other error in your code..

without error handling you just don't see it.

in your script you can catch the exception like this:

try {
    if (platformType.equals("android")) {
        return ['7.0', '6.0']
    } else if(platformType.equals("ios")) {
        return ['10.0', '9.0']
    }
}catch(e){ return [e.toString()] }

in this case you'll see the error in your choice field

Upvotes: 8

Related Questions