Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Bitbucket Branch Source Plugin how to build only master and PR?

I'm using Jenkins 2 with the Bitbucket Branch Source Plugin which scans and builds all the branches and PRs.

My problem is that when I push code to a PR, the branch is built twice (one for the branch and one for the PR). I would like to build only master and PRs.

Do someone knows how to do that ? I can't find any documentation about this.

From the Branch Indexing Log (wihtout filter):

Checking branch branch-name from repo/project
Met criteria
Scheduled build for branch: branch-name
...
Checking PR from repo/project and branch branch-name
Met criteria
Scheduled build for branch: PR-123

Then when I try to filter on PR-* nothing is scanned. I just get:

Checking branch branch-name from repo/project
like image 993
Pith Avatar asked Sep 29 '16 10:09

Pith


2 Answers

You can just separate your terms with a space. For your include try:

master PR-*
like image 173
Mike Neary Avatar answered Nov 19 '22 19:11

Mike Neary


When you are configuring your Bitbucket sources, you can use Include branches or Exclude branches (in Advanced params) to include/exclude some branches :

enter image description here

And based on Bitbucket Branch source plugin source code, both fields takes an Ant regex.

So assuming all your PR branches start with "pr-" you could use a regex in include branches, e.g. :

(?:master|pr-).*
like image 34
Pom12 Avatar answered Nov 19 '22 18:11

Pom12