| Hello, While I was reading some JIRA ticket, I found the non-official Jenkins plugin Git Chooser Build Branches, which defines a build branch strategy that allows Jenkins to build the same commit that was built previously, considering a different branch. I am going to describe step-by-step how to configure, from webhook (Bitbucket) to the job configuration, in case someone else is trying to achieve the same goals. 1. Install the following Jenkins plugins:
2. On Bitbucket:
- Access your repository settings
- Access Webhooks -> Add Webhook
- In URL, you should inform: YOUR_JENKINS_URL/bitbucket-hook/. Note that the trailing slash is required.
- Configure the remaining fields as you wish
3. On Jenkins:
- In your job, mark "This build is parameterized"
- Add a string parameter BRANCH with the wildcard that you want, say origin/*.
- Configure your SCM and in "Branches to build", inform the same parameter specified before. In our case, $BRANCH.
- In Git "Additional Behaviours", add "Strategy for choosing what to build", selecting "Build branches". Also, add "Force polling using workspace".
- In "Build Triggers", check "Build when a change is pushed to BitBucket".
That's it. When you push something in your repository (branch creation or push in existing branches), the job will be triggered. |