Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Server webhook to jenkins

Deleted user January 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
Mario Carabelli
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2019

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 January 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"?

Mario Carabelli
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2019

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 January 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?

Mario Carabelli
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2019

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

kylekaja123 March 29, 2019

@[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
AUG Leaders

Atlassian Community Events