Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BitBucket+Jenkins: Trigger build only when specific branch is changed

The following is a purported solution to the problem, although it does seem like a workaround rather that a definitive solution. Is there a way, through either job config or bitbucket hook config, that I can set my jobs to run a build only when a specific branch is pushed to?

Is it possible to trigger Jenkins from one specific branch only?

It has been about a year since the posting of that question, I'm hoping there's been some plugin updates to allow for this without the extra work required in the above link, or perhaps there's always been an easy way that I'm just not seeing.

like image 952
Matt MacLeod Avatar asked Dec 25 '22 01:12

Matt MacLeod


1 Answers

As @Ryan Taylor already said you can use the Bitbucket-Plugin:

  • 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.

And best of it, you don't have to ad new hooks for new Jenkins projects.

like image 109
salcosand Avatar answered Jan 24 '23 04:01

salcosand