Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Bitbucket Server webhook to jenkins

Edited
Deleted user Jan 19, 2019

I created a webhook in bitbucket server to trigger jenkins job automatically when change pushed into bitbucket.i have done this with bitbucket plugin and generic webhook trigger plugin but its not trigger the job.

i didnt enable "bitbucket server webhook to jenkins" in bitbucket post receive hooks and its showing that it cost 10$.Is it is the issue with this?

Is there any way to trigger without that add-on?

1 answer

1 accepted

0 votes
Answer accepted

Hey Vishwanath,

I had the same issue once. In my case the bitbucket server was in a private network and the jenkins server in a public one. This stopped the webhook besides the correct configuration.

Could this be your problem too?

With kind regards,

Mario

Deleted user Jan 19, 2019

Hi Mario Carabelli,

Thank you for your suggestion.But is it trigger job within same network without buying that add-on in post receive hooks-"bitbucket server webhook to jenkins"?

Okay then your case is different.

For a basic trigger you should be fine with the native bitbucket and without the plug-in. Since v5. 0 bitbucket has webhooks built in.

But if you use the interface of the plug-in and the functionality of it is disabled this can of course be the reason for your hook not triggering.

Here is the documentation on how to use bitbucket native weghooks:

https://confluence.atlassian.com/bitbucketserver050/managing-webhooks-in-bitbucket-server-964970400.html

Best of luck!

Deleted user Jan 20, 2019

I tried the same blog without using any plugin in bitbucket. I created webhook with slash in ending and its showing status 200 but build is not triggered in jenkins. I am not understanding whats the issue with this?

And one more thing if bitbucket is in private network and jenkins in public network, is it trigger build or not?

Hi @[deleted]

To be totally honest I am lost there too. Maybe the jenkins user specified in the hook does not have the necessary permission to trigger the build?

I mean as far as I understand it if you get 200 back the http request was send successfully. This would mean the problem lies most likely in the jenkins config or the form of the webhook url.

If you have bitbucket in a private network it can't send requests to servers outside of the network. This means the trigger in bitbucket is triggered but the request will return 404.

Deleted user Jan 20, 2019

Hi

The user specified in URL has all the permissions i.e admin and i tried with my personal bitbucket its triggering and everything works fine.But here i'm working with bitbucket server v5.10.0. In this version, its showing this problem.

Deleted user Jan 24, 2019

Hi @Mario Carabelli

Its working fine with generic webhook trigger.

Now i want to trigger build only when tag is pushed so I followed the blog:

https://github.com/jenkinsci/generic-webhook-trigger-plugin/blob/master/src/test/resources/org/jenkinsci/plugins/gwt/bdd/bitbucket-server/bitbucket-server-tag.feature

Its triggering for both commits and tags. But i want to trigger build only when tag is pushed not for commits.

Is it possible?

please help me with this issue.

@[deleted],

It doesn't seem like this could be done with just the Generic Webhook Trigger plugin alone. The event payloads for Bitbucket Server do not contain information about tags. See the Push event payload on this page: https://confluence.atlassian.com/bitbucketserver/event-payload-938025882.html.

One alternative you could do is to allow the job to build after the commit is pushed, but check for the tag early in the build. To do this, make a HTTP GET request to the server (e.g. a curl command). I think the REST API for tags might be useful for your case: https://docs.atlassian.com/bitbucket-server/rest/6.1.2/bitbucket-rest.html#idp317. This will give you a list of tags on a repository. Compare the latestCommit value with the commit id that triggered the build (retrieved by the Generic Webhook Trigger plugin). If a match is found, continue with the build. When a match is not found, that means that the job was not triggered by a tag push and the job should stop.

It may not solve your problem exactly the way you hope it would, but it might be a satisfactory workaround.

Suggest an answer

Log in or Sign up to answer
TAGS
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...

4,459 views 12 15
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