You should wrap your code into script
function
https://www.jenkins.io/doc/book/pipeline/syntax/#script
or declare your variable before pipeline {
pipeline {
agent any
environment {
PATH = "/usr/local/bin:$PATH"
}
stages {
// The pipeline will fail it can't find terraform
stage("Check terraform") {
steps {
script {
String CMD = (env.DESTROY.toBoolean ? "destroy" : "apply")
}
// other steps
}
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…