Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Jenkins only build feature branches if they have changed when triggering from bitbucket

I have a Jenkins job that builds branches that match "origin/feature/**".

Bitbucket triggers the job to build whenever there are changes to the repository via a repository hook (https://confluence.atlassian.com/display/BITBUCKET/Jenkins+hook+management).

This works fine whenever there is a change on a feature branch, the job recognizes that the branch has changed and builds it.

However, when there is a commit to a non-feature branch (eg. a merge to develop or master) bitbucket still triggers the job. There are no changes to any of the feature branches so it just builds the last built feature branch again.

Is there a way to control this?

like image 837
YakobeYak Avatar asked Sep 25 '13 11:09

YakobeYak


Video Answer


1 Answers

After some research I found a good solution finally:

  • Install Bitbucket Plugin at your Jenkins
  • Add a normal Post as Hook to your Bitbucket repository (Settings -> Hooks) and use following url:

https://YOUR.JENKINS.SERVER:PORT/bitbucket-hook/

  • Configure your Jenkins project as follows:
    • under build trigger enable Build when a change is pushed to BitBucket
    • under Source Code Management select GIT; enter your credentials and define Branches to build (like **feature/*)

By this way I have three build projects, one for all features, one for develop and one for release branch.

like image 69
salcosand Avatar answered Oct 23 '22 12:10

salcosand