Jenkins工作DSL由“由SCM更改启动”触发

时间:2017-05-16 04:18:49

标签: jenkins jenkins-job-dsl

我正在编写一个DSL作业,只有在打开或关闭拉取请求时才会触发构建(使用webhooks)。但是,在Jenkins中,我可以看到在打开pull请求时触发了三个构建 - 一个用于拉请求,另一个用于SCM更改。

如何阻止构建“由SCM更改启动”?

job("dummyjob"){
      description('Apply pull request patch, build image and store in archive.')
      scm {
          git {
              remote {
                  github("user/${project.name}")
                  refspec('+refs/pull/*:refs/remotes/origin/pr/*')
              }
          }
      }

      triggers {
          onPullRequest {
              setPreStatus()
              cancelQueued()

              mode {
                  cron('') //null means no cron (else default 5 minutes), dependent only on hooks
                  heavyHooks()
              }

              events {
                  opened()
                  closed()
              }
          }
      }

      steps {
            updateStatusOnGH {
              message('Building...')
            }
      }
}

这是使用Github集成插件

1 个答案:

答案 0 :(得分:0)