Jenkins setup: Docker container with version 2.447
Currently, I am using the Active Choices plugin to configure my pipeline. I have 3 different parameters that are used to build the pipeline.
The 2nd parameter, updates on the value selected for the 1st parameter. The 3rd parameter, updates on the value selected for the 2nd parameter.
However, what I observe is that the value of the 3rd parameter remains the same for that particular build number ( irrespective of any different option selected in 2nd parameter). The 3rd parameter value(in the current build) is the value of the results from the click of 2nd parameter(in the previous build)
For eg: In the second parameter, I select branch2. IFF i had selected branch2 in my previous build for 2nd parameter, it would show me the values: model3,model4. IFF NOT, then some other values all together.
Image:
The MODEL_INFO is not updated there.
properties([
parameters([
[$class: 'CascadeChoiceParameter',
choiceType: 'PT_SINGLE_SELECT',
name: 'RUN_TESTS',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script: 'return ["ERROR"]'
],
script: [
classpath: [],
sandbox: true,
script:"""
return ["YES","NO"]
"""
]
]],
[$class: 'CascadeChoiceParameter',
choiceType: 'PT_RADIO' ,
name: 'BRANCH',
referencedParameters: 'RUN_TESTS',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script: 'return ["ERROR"]'
],
script: [
classpath: [],
sandbox: true,
script:"""
if(RUN_TESTS.equals("YES")){
return ["${getDummyBranches().join('","')}"]
}else{
return ["Disabled: Select 'Yes' to enable"]
}
"""
]
]] ,
[$class: 'CascadeChoiceParameter',
choiceType: 'PT_CHECKBOX',
//choiceType: 'PT_RADIO' ,
name: 'MODEL_INFO',
referencedParameters: 'BRANCH',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script: 'return ["ERROR"]'
],
script: [
classpath: [],
sandbox: true,
script:"""
if(BRANCH!=null && !BRANCH.isEmpty() && !BRANCH.contains("Disabled:")){
return ["${getDummyModels(BRANCH).join('","')}"]
}else{
return ["Disabled: Select the appropriate branch above"]
}
""" ]
]]
])
])
def getDummyBranches() {
return ["branch1", "branch2", "branch3"]
}
def getDummyModels(valu) {
if (valu.equals("branch1")) {
println("inside the branch1 condition")
return ["model1", "model2"]
} else if (valu.equals("branch2")) {
println("inside the branch2 condition")
return ["model3", "model4"]
} else {
return ["model5", "model6"]
}
}
node {
stage('Print Parameters') {
println "xxx"
}
}
Where am I going wrong here? Or am I missing something conceptually