New to Jenkins and currently working on a job that needs a parameter with a list of items and a "false/true" state for each. My idea was to do this with an extended choice parameter but the "output" of that is a list with only the items that are checked. Is there a way to do something similar but also get a list with the items that are not checked?
Am aware of other ways to manage this but I am just interested if the idea presented above is possible.
The output value for Test_p would be: "CTA,RSP2". Looking on how to also get "EM,SPM,PRIME" as unchecked values
One way to solve this would be to define the available choices in a variablle and then calculate the difference between what's selected and what is not selected:
import groovy.transform.Field
@Field testPChoices = 'EM,CTA,SPM,RSP2,PRIME'
pipeline {
agent none
parameters {
extendedChoice(
name: 'Test_p',
type: 'PT_CHECKBOX',
value: testPChoices,
)
}
stages {
stage('Hello') {
steps {
echo "Selected ${params.Test_p}"
echo "Not selected ${testPChoices.split(',') - params.Test_p.split(',')}"
}
}
}
}