Bitbucket Pull Request Jenkins Job

1.6k views Asked by At

I want to trigger a job in Jenkins whenever a pull request is created in Bitbucket. I have used Bitbucket Pull Request Builder for this and set up the refspec and branch specifier as follow:

  1. Refspec: +refs/pull/*/head:refs/remotes/origin/pr/*
  2. Branch Specifier: pr/*/from

But Jenkins job is picking the last merged branch not the source branch of the open pull request.

enter image description here

Please help me with this or provide me with a clean solution to create a pipeline to trigger a job whenever a pull request is created in Jenkins

1

There are 1 answers

2
Adiii On BEST ANSWER

I would prefer Generic+Webhook+Trigger+Plugin instead of BitBucket it provides everything in the payload when pull request created.

enter image description here

Here are the steps

  • Create Webhook in Bitbucket enter image description here

  • add Your Jenkins Remote URL in the webhook enter image description here

  • Handle payload on Jenkins side using Generic Webhook enter image description here

You can check details integration here