<p>This is how I've setup my BitBucket Pull Requests Builder.</p>

<p><a href="https://i.sstatic.net/2woNF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2woNF.png" alt="Pull Request Builder Example"></a></p>

<p><strong>CRON</strong></p>

<p>Use <code>* * * * *</code> and it will poll BitBucket every minute to check for PRs.</p>

<p><strong>Credentials</strong></p>

<p>Setup a shared credential that you can use amongst all projects.</p>

<p><strong>Repo Owner &amp; Name</strong></p>

<p>You should take the data from your repo URL/SSH like:</p>

<p><code>git@bitbucket.org:REPO_OWNER/REPO_NAME.git</code></p>

<p><strong>Branches Filter</strong></p>

<p>You can choose to only build specific branches or leave it blank to build all.</p>

<p><strong>CI Identifier &amp; Name</strong></p>

<p>I set this as the name of our CI account we setup on BitBucket. If you create a new BitBucket account just for your pull requests, grant permission to the repositories that it needs. Then whatever username you set that new account to have enter it as the CI Name and CI Identifier.</p>

<p>Finally, leave the bottom two options ticked.</p>

<p>That's the settings that work for us.</p>

CC BY-SA 3.0
2017-04-03T17:00:56.803Z
The way you suggest working fine.. But the build also triggered whenever there is changes happened to bitbucket...
kumar
CC BY-SA 3.0
2017-03-30T18:58:32.493Z
2017-03-30T19:24:25.253Z
2017-03-30T19:24:25.253Z
ajtrichards
<p>You can install 'Bitbucket Server Webhook to Jenkins' in Bitbucket. 
<a href="https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview" rel="nofollow noreferrer">https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview</a></p>

<p>Once install you will need to enable the 'Post Receive' Hook on the required repository.</p>

<p>Remember to enable '<strong>poll SCM</strong>' for the Jenkins Job.</p>

<p><strong>Update</strong>
You can test the configuration of the plugin here:
<a href="https://i.sstatic.net/E4lYe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/E4lYe.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2017-03-30T16:16:33.187Z
Thanks for infor Kyle... I tried the way you suggested but still its not working..                                                                                                            (I am using jenkins version 2.34) .
kumar
CC BY-SA 3.0
2017-03-30T16:27:10.307Z
Installed Post Receive Web hook on particular repo.. Entered the URL (http://p-gp2-apjsjenkins-1.imovetv.com/bitbucket-hook/) & Enabled it                                                                                                                                   (I am using jenkins version 2.34) .
kumar
CC BY-SA 3.0
2017-03-30T17:05:30.043Z
Hi Kumar, Can you provide me with more information on the error you are receiving or the console output you are receiving?
Kyle Steenkamp
CC BY-SA 3.0
2017-04-03T17:59:23.927Z
Hi Kyle....  The build triggering successfully when there is open pull request.. at the same time its also triggering for scm changes to that repo...
kumar
CC BY-SA 3.0
2017-03-30T08:02:10.557Z
2017-12-16T09:09:51.280Z
2017-12-16T09:09:51.280Z
Kyle Steenkamp
<p>We were able to achieve this using Jenkins multibranch pipeline, upon pull request creation and update pipeline would create a new job. It'll check out the pull request so we can build / run unit tests / sonarqube analysis on it.</p>
<p>Refer following for step by step guide,
<a href="https://www.whatsuptec.com/trigger-jenkins-pipeline-on-bitbucket-pull-request/" rel="nofollow noreferrer">https://www.whatsuptec.com/trigger-jenkins-pipeline-on-bitbucket-pull-request/</a></p>

CC BY-SA 4.0
2020-05-15T16:45:21.227Z
Please add the steps that are required to prevent that these will be lost if the URL gets deprecated.
030
CC BY-SA 4.0
2020-05-15T15:46:28.713Z
2020-12-28T14:58:34.210Z
2020-12-28T14:58:34.210Z
user22293
<p>I need to integrate BitBucket with Jenkins, so that whenever a PR is opened in BitBucket, it will trigger a build in Jenkins. Can someone help describe the exact configuration step that I should follow in BitBucket and Jenkins to achieve this?</p>
<p>This is my configuration so far:</p>
<p><a href="https://i.sstatic.net/am4fb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/am4fb.png" alt="enter image description here" /></a></p>

<jenkins>
Bitbucket Pull Request Builder Configuration Jenkins
kumar
# Bitbucket Pull Request Builder Configuration Jenkins

(Asked by: username_0 on 2017-03-29)

I need to integrate BitBucket with Jenkins, so that whenever a PR is opened in BitBucket, it will trigger a build in Jenkins. Can someone help describe the exact configuration step that I should follow in BitBucket and Jenkins to achieve this?

This is my configuration so far:

[![enter image description here](https://i.sstatic.net/am4fb.png)](https://i.sstatic.net/am4fb.png)

**Tags:** jenkins


---

## 3 answers

### Answer by username_2 on 2017-03-30. Score: 9

You can install 'Bitbucket Server Webhook to Jenkins' in Bitbucket.
<https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview>

Once install you will need to enable the 'Post Receive' Hook on the required repository.

Remember to enable '**poll SCM**' for the Jenkins Job.

**Update**
You can test the configuration of the plugin here:
[![enter image description here](https://i.sstatic.net/E4lYe.png)](https://i.sstatic.net/E4lYe.png)

> **Comments:**
> **username_0**: Thanks for infor Kyle... I tried the way you suggested but still its not working..                                                                                                            (I am using jenkins version 2.34) .  
> **username_0**: Installed Post Receive Web hook on particular repo.. Entered the URL (http://p-gp2-apjsjenkins-1.imovetv.com/bitbucket-hook/) & Enabled it                                                                                                                                   (I am using jenkins version 2.34) .  
> **username_2**: Hi Kumar, Can you provide me with more information on the error you are receiving or the console output you are receiving?  
> **username_0**: Hi Kyle....  The build triggering successfully when there is open pull request.. at the same time its also triggering for scm changes to that repo...  

---

### Answer by username_1 on 2017-03-30. Score: 4

This is how I've setup my BitBucket Pull Requests Builder.

[![Pull Request Builder Example](https://i.sstatic.net/2woNF.png)](https://i.sstatic.net/2woNF.png)

**CRON**

Use `* * * * *` and it will poll BitBucket every minute to check for PRs.

**Credentials**

Setup a shared credential that you can use amongst all projects.

**Repo Owner & Name**

You should take the data from your repo URL/SSH like:

`git@bitbucket.org:REPO_OWNER/REPO_NAME.git`

**Branches Filter**

You can choose to only build specific branches or leave it blank to build all.

**CI Identifier & Name**

I set this as the name of our CI account we setup on BitBucket. If you create a new BitBucket account just for your pull requests, grant permission to the repositories that it needs. Then whatever username you set that new account to have enter it as the CI Name and CI Identifier.

Finally, leave the bottom two options ticked.

That's the settings that work for us.

> **Comments:**
> **username_0**: The way you suggest working fine.. But the build also triggered whenever there is changes happened to bitbucket...  

---

### Answer by username_3 on 2020-05-15. Score: 0

We were able to achieve this using Jenkins multibranch pipeline, upon pull request creation and update pipeline would create a new job. It'll check out the pull request so we can build / run unit tests / sonarqube analysis on it.

Refer following for step by step guide,
<https://www.whatsuptec.com/trigger-jenkins-pipeline-on-bitbucket-pull-request/>

> **Comments:**
> **username_4**: Please add the steps that are required to prevent that these will be lost if the URL gets deprecated.  

---

