我有一个声明式管道。我正在尝试仅在每8次提交后使Jenkins触发构建。 我是Jenkins的新手,如何根据提交号触发构建?
答案 0 :(得分:1)
假设每次提交都会触发构建:
pipeline
agent any
stages {
stage('Check 8 commits') {
steps {
def build_num = env.BUILD_NUMBER as int
if (build_num % 8 != 0) {
error "This is not 8th commit"
}
}
}
}
}