Showler
Showler

Reputation: 93

Trigger Jenkins Job from Bitbucket on Pull Request

Hoping to gather insight from professionals. My end goal is to trigger a jenkins build whenever a bitbucket pull request happens. If anyone could give me an ELI5(explain like I am 5) answer it would be greatly appreciated. Sorry if this is the wrong format, I am new to jenkins and stackoverflow.

What I have done so far:

  1. Created webhook in bitbucket and gave the url to my jenkins job. example: http://jenkinsURL:8080/job/boulevard-dev/generic-webhook-trigger/invoke?token=myPull_Request_Token

  2. Pull request webhook trigger

  3. In Jenkins, under source code management I have: Source Code Management Settings. This is currently fetching a ton of branches, failing, then building the master branch when the job starts?

  4. For build triggers, other stackoverflow articles have pointed me to the "Generic Webhook Trigger". https://github.com/jenkinsci/generic-webhook-trigger-plugin

  5. I am not entirely sure how this generic webhook trigger should effectively be setup? Hoping someone has experience using it and could explain what is needed.

  6. This is what have seen referenced in other articles.Build Triggers settings Build triggers settings 2

Questions:

Upvotes: 9

Views: 24418

Answers (1)

Rahul Gaikwad
Rahul Gaikwad

Reputation: 589

As per your requirement, you can trigger a Jenkins build whenever a bitbucket pull request happens by following the below steps, in my case, it's working fine.

Step(1) - Configure Jenkins
(i) Add your bitBucket repo and branch to source code management enter image description here (ii) On build Triggers setup Poll SCM to * * * * * for run every minute to check pull request from bitBucket. enter image description here

Step(2) - configure Bit Bucket Hook
(i) Go to settings and add a new hook, now setup pull request trigger as per your requirement. enter image description here

Step(3) - Make a pull request and see the new job automatically triggered on Jenkins. enter image description here

Upvotes: 8

Related Questions