I wish to abort the pipeline if the user did not select any value for Active Choice parameter for single/multi choice/string pipeline parameter.
For example I have Active Choices Reactive Parameter Named "IPAddress" of Type "Multi Select" with Groovy Script as below:
if (Location.equals("MyTown")) {
return["DDL1", "DDL2", "DDL3", "DDL4"]
} else if (Location.equals("Your Town")) {
return["DDP1", "DDP2"]
} else {
return ["Select an IP from the drop-down"]
}
Thus, once I run the pipeline i see "Select an IP from the drop-down" for IPAddress.
Now, If the user does not select anything from the dropdown the pipeline should fail & abort.
In the pipeline script I have written the below condition check which fails to check the condition despite user ignoring to select any IPAddress.
def ex(param){
currentBuild.result = 'ABORTED'
error('BAD PARAM: ' + param)
}
pipeline {
agent any
stages {
stage ("Pre-Check Parameters") {
steps {
echo "Pre-Check called in pipeline"
script {
if ("${params.IPAddress}" == null) {ex("IPAddress")}
//if ("${params.myEnv}" == null) {ex("b")}
//if ("${params.myLoc}" == null) {ex("c")}
}
}
}
}
}
Can you please suggest what could be the issue here ?
Aucun commentaire:
Enregistrer un commentaire