且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有条件地启用Jenkins声明性管道选项吗?

更新时间:2022-12-17 12:11:20

您可以使用

You can use the Lockable Resources Plugin to guarantee that the problematic steps do not run in parallel when on the master branch.

类似的东西:

stage('on master') {
    when {
        branch 'master'
    }
    steps {
        lock(label: 'choose_a_label') {
            // your steps
        }
    }
}


stage('not on master') {
    when {
        not {
            branch 'master'
        }
    }
    steps {
        // your steps
    }
}