How to write conditional step with boolean parameter in jenkins scripted pipeline job?
You need to convert this environment variable (of type string) to boolean using toBoolean() function:
stage('test cond'){
if(env.BUILD_TESTING2.toBoolean()){
echo "Yes equal - running the stage"
} else {
echo "Not equal - skipping the stage"
}
}
Better reference parameters by params instead of env, this way they have the correct object type. So use:
stage('test cond') {
if(params.BUILD_TESTING2) {
echo "Yes equal - running the stage"
} else {
echo "Not equal - skipping the stage"
}
}