Jenkins区分PR和合并webhooks

时间:2018-04-17 23:21:52

标签: jenkins github jenkins-pipeline jenkins-github-plugin

因此,每个作业只能有一个Jenkins文件。我们与github的合并和公关webhooks共享同样的工作。我们如何才能轻松检测PR中的提交的webhook是否被推入PR合并?

1 个答案:

答案 0 :(得分:1)

此(声明性管道)代码段可能会有所帮助:

        stage('do something for PRs opened against develop branch') {
          when {
            changeRequest target: 'develop'
          }
          steps {
            sh 'pr-worker.sh'
          }
        }

        stage('do something on merge or direct commits to the develop branch') {
          when {
            branch 'develop'
          }
          steps {
            sh 'develop-worker.sh'
          }
        }