hyde1004
hyde1004

Reputation: 267

Jenkins Active Choices Parameter plugin not working when Build Triggers

I'm using Active Choices Parameter plugins.

It works well but it doesn't work when triggered by 'Build Triggers' - Build periodically.

When running by 'Build periodically',
I expected the value of SEASON is 'spring' and FRUIT is 'apple'.

I think that the 'SEASON' variable isn't recognized in Groovy script.

What should I check?

enter image description here

enter image description here

enter image description here

enter image description here

This is started by Build Triggers: enter image description here

This is started by me: enter image description here

Upvotes: 2

Views: 1553

Answers (1)

hyde1004
hyde1004

Reputation: 267

According to https://github.com/biouno/uno-choice-plugin/#known-limitations,
the parameters are supposed to be handled only by humans, and at the moment do not work when the job is triggered by plug-ins, API or scripts.

So, I did workaround using a default value:

try {
    if ( SEASON == "spring" ) {
        return [ "apple" ]
    } else if ( SEASON == "summer" ) {
        return [ "banana" ]
   } else {
        return [ "cherry" ]
    }
} catch (e) {  /* if variable is missing, return the default value */
    return [ "apple" ]
}

Upvotes: 1

Related Questions