Atlassian Bitbucket Integration plugin triggers builds for multiple branches

Issue symptoms: 

A push to Bitbucket triggers builds for multiple branches, not only the branch that has received the most recent push.

Explanation:

Official Atlassian Jenkins integration plugin checks Bitbucket Server for any changes in a repository with a configured webhook to Jenkins since the last build was triggered. If a change is found - it builds all the branches that have changed.

Let’s consider a situation:

Situation 1:

  1. A user pushes a commit to branch FEAT-1.1.1.

  2. An Auto-merging feature is enabled propagating the changes to FEAT-1.1 and Release branches.

Result:

Jenkins builds branches FEAT-1.1.1, FEAT-1.1, and Release.

Situation 2:

  1. Jenkins instance is brought down for maintenance.

  2. A user pushes changes to branches FEAT-1.1, FEAT-2.0, and BUGFIX-456.

  3. Jenkins instance is brought back up.

  4. A user pushes changes to branch FEAT-2.0.

Result:

Branches FEAT-1.1, BUGFIX-456, and FEAT-2.0 (the most recent commit) will be built in Jenkins.

Once the push to FEAT-2.0 happens and communication between Bitbucket Server and Jenkins is up and running again, the Jenkins plugin will scan the whole repository in Bitbucket Server for changes since the last scan. It should discover updates to not only the most recently updated branch but also all the others not built yet.


If your intention is to build a specific branch, feel free to use Branch Specifier in 'Branches to build' in Jenkins build configuration:

Last modified on Jan 6, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.