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

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


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.


The answer was in the comments section you linked to. Bitbucket will always call the hook to your job.

You need a proxy in front of Jenkins to segregate out posts.

https://github.com/oveddan/gitBuildForwarder

If this was SVN, I would tell you how to alter the SVN hook to only selectively trigger the hook based on Regex filtering.


Since i can not answer the comment top (whyever)

"you are correct but I want to do in jenkins pipeline job"

To let a pipeline-job build automatically after a push (per hook) i created another job that is configured just to be triggered by the bitbucket/git and has a follow-up job that points to the pipeline-job in the post-build-action. That was the only way i could manage this