Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Limit webhook trigger on specific branch

I have setup a webhook in Bitbucket to trigger a jenkins build on every push.

The issue is that my jenkins build itself will make create a tag for the release candidate and pushes it to bitbucket.

This creates an infinite loop of builds.

Is there a way to limit the trigger to a specific branch? For example the webhook triggers on a push to master but not when a tag is pushed.

3 answers

Hi Cesar,

Is there no way for you to change your build such that it only pushes a tag to Bitbucket for a specific branch? The webhook from Bitbucket has to include the name of the branch.

I'm no PM, but I would imagine that one has more flexibility to write scripts how they please on the Jenkins side and hence perhaps the challenge of filtering branches is better tackled there.

Hi Abhin, thanks for your help.

I'm not sure what you mean by pushing a tag for a specific branch. In Git tags are objects like commits and branches. Pushing can involve any of them.

Jenkins has a REST API that allow you to trigger a build. Once the call to the API is made, it will trigger a build. 

I'm using the cloud version of Bitbucket and I can't specify a branch name for the trigger:

Screen Shot 2016-07-12 at 07.10.21.png

I'll continue looking for a way to prevent Jenkins from building on trigger if the desired branch has not changed.

Hi Cesar,

I totally didn't phrase that right. What I'm getting at is that when Jenkins starts a build (after being triggered by a BB webhook), it must run some script that you wrote that then does the tagging (and pushing). From what I understand, the problem you're facing is that push from the build triggers yet another webhook etc. But I suspect that you can break the loop from your own script using some sort of pre-condition that must be satisfied before your script decides to tag the release candidate and push the tag. 

Does you build script have access to the payload of the webhook? If so, the payload contains what was pushed. You should be able to then notice that the push only contained a tag and that the name of the tag matched the pattern you must use for your release candidates. Based on that pre-condition, you could choose to not tag again and push the tag.

Please let me know if that works for you.


There does not seem to be an answer because I have looked for the same information but never found a solution.

I solved this problem by forcing people to commit with a tag like 




So I have a git check step that checks the last commit. If it has [CI] it continues and do all the voodoo tricks to commit, transit, comment in ticket from the pipelines, but if it doesn't I do an

exit 0


The pipeline is stopped and I also save lots and lots of minutes triggered by "backup" pushes. :-) 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

222 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you