Can I use webhooks to trigger different Jenkins build jobs for different repo branches?
Asked by suchpower:

I recently moved some repositories from a deprecated Bitbucket Server installation to Bitbucket cloud.

In my repository I'd like to trigger different Jenkins build jobs for different repo branches.

For example, a push to the \`develop\` branch should trigger a Jenkins job to build the project on my staging site while a push to the \`master\` branch should trigger a separate Jenkins job to build the project on my production site. I don't see options for that kind of differentiation in the webhook settings.

On Bitbucket Server I was able to specify branches on the Bitbucket side (via a Bitbutcket/Jenkins integration plugin, I believe) to send requests to different Jenkins jobs based on the specified branch(es). The examples \& tutorials I've seen for a Bitbucket Cloud/Jenkins setup only seem to connect up via the Jenkins server URL. Who knows which job it will trigger when the request hits Jenkins?

Can I use webhooks to accomplish this?

Can pipelines accomplish this?

What is the recommended approach for this sort of workflow?


Answers:
author: jennifer.dempsey_Appfire
body: Hi [@suchpower](/t5/user/viewprofilepage/user-id/5261759)

Can you tell me which Bitbucket/Jenkins integrations plugin you're using? I'm the Product Marketing Manager for Appfire's [Webhook to Jenkins for Bitbucket Cloud](https://marketplace.atlassian.com/apps/1211284/webhook-to-jenkins-for-bitbucket?tab=overview&hosting=cloud).

Best,

Jennifer

comments: author: suchpower
body: Let's see...in the Jenkins plugin manager I see "Bitbucket Plugin" and "Bitbucket Push and Pull Request Plugin" installed. I inherited this Jenkins installation so I'm guessing I may not need both of those.

The Webhook to Jenkins for Bitbucket Cloud looks like exactly what I need! Where in Bitbucket Cloud do I add/manage integrations?


author: jennifer.dempsey_Appfire
body: Hi [@suchpower](/t5/user/viewprofilepage/user-id/5261759)

Great! I'm happy we have a solution for you. I'm going to reach out to a member of our Support team to help you with your question regarding adding/managing your integrations. They'll be happy to walk you through the set up process. Someone will reach out to you soon.

Best,

Jennifer


author: Naveen Kumar_Appfire
body: Hi [@suchpower](/t5/user/viewprofilepage/user-id/5261759)

Hope you are doing well,

We have created a support request [SUPPORT-96982](https://appfire.atlassian.net/servicedesk/customer/portal/11/SUPPORT-96982) However, we couldn't add you as a reporter.

<br />

Please sign up using this link [sign up](https://appfire.atlassian.net/servicedesk/customer/portal/11/user/login) and share with us the user name or id.  
We will then add you as the reporter and confirm.

As per my understanding, you would like to integrate jenkins with Bitbucket. For this after installing the WJB Cloud app. In the repository setting tab, you have the **CONFIGURING WEBHOOKS TO JENKINS**option to add/integrate the Jenkins instance as below.

![2023-07-07_18-14-34.png](https://community.atlassian.com/t5/image/serverpage/image-id/267454i68943A1A46DE118C/image-size/large?v=v2&px=999 "2023-07-07_18-14-34.png")

Thanks,  
Naveen


Tags: bitbucket-cloud

cloud

jenkins

webhook