Jenkins build triggered twice when merging branch

2019-04-10 15:27发布

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?

1条回答
乱世女痞
2楼-- · 2019-04-10 16:10

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
}
查看更多
登录 后发表回答