1
votes

I am writing a DSL job to trigger a build only when a pull request is opened or closed (using webhooks). However, in Jenkins, I can see three builds being triggered when I open a pull request - 1 for pull requeste and 2 for started by SCM change.

How can I prevent the builds "Started by SCM change"?

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...')
            }
      }
}

This is using Github Integration plugin

1

1 Answers