Arnoldas Liudžius
Arnoldas Liudžius

Reputation: 349

Jenkins build triggered twice when merging branch

A project with Jenkins integration has selected option: Build when a change is pushed to BitBucket. Everything works as expected until some other branch is merged to master. In this case Jenkins triggers two builds. Has anyone experienced this issue?

Upvotes: 4

Views: 3003

Answers (1)

Marcin Kłopotek
Marcin Kłopotek

Reputation: 5931

I have experienced the same issue only for master branch, like you. The solution that worked was to update Build Triggers configuration of the job that was triggered twice by leaving Poll SCM -> Schedule text box empty (no Cron expression entered). So the proper configuration is to only mark the two trigger options:

  1. [✓] Build when a change is pushed to BitBucket
  2. [✓] Poll SCM (leave the Schedule text box empty)

enter image description here

In case Jenkins Job DSL plugin is used for generating the build job, it should contain proper triggers block (which corresponds to the above screen):

triggers {
  bitbucketPush()
  scm('') // empty Cron expression string
}

Upvotes: 1

Related Questions