如何在我的Jenkinsfile中指定類似以下內容的東西?如何在jenkinsfile中指定分支NOT(分支名稱)?
當分支不是X
我知道如何指定像分支的具體任務:
stage('Master Branch Tasks') {
when {
branch "master"
}
steps {
sh '''#!/bin/bash -l
Do some stuff here
'''
}
}
但是我想指定分支時沒有掌握或分期像一個舞臺以下:
stage('Example') {
if (env.BRANCH_NAME != 'master' && env.BRANCH_NAME != 'staging') {
echo 'This is not master or staging'
} else {
echo 'things and stuff'
}
}
但是上面並沒有與下面的錯誤工作和失敗:
WorkflowScript: 62: Not a valid stage section definition: "if
WorkflowScript: 62: Nothing to execute within stage "Example"
爲我的失敗嘗試注來源:https://jenkins.io/doc/book/pipeline/syntax/#flow-control