Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell Jenkins to compile some, but not all branches of a repository?

Tags:

git

jenkins

At my place of work, we use a 2 letter coded naming convention when creating git branches. For example, feature Apple, might be ftr_ap_hotfix and feature Orange might be done in branch ftr_or_hotfix.

I want to create two separate jobs in Jenkins. One job should compile all branches that match the name **_ap_** and the other job should compile all branches that match the name **_or_**

However, when I set this up, Jenkins is compiling all branches no matter their name.

What am I doing wrong? Is there a better way to do this?

The only help I get from the Jenkins page is as follows:

Specify the branches if you'd like to track a specific branch in a repository. If left blank, all branches will be examined for changes and built. The syntax is of the form: REPOSITORYNAME/BRANCH. In addition, BRANCH is recognized as a shorthand of */BRANCH, '*' is recognized as a wildcard, and '**' is recognized as wildcard that includes the separator '/'. Therefore, origin/branches* would match origin/branches-foo but not origin/branches/foo, while origin/branches** would match both origin/branches-foo and origin/branches/foo.

like image 316
Avik Avatar asked Dec 11 '12 09:12

Avik


1 Answers

As commented, It might be possible that it would work only for hierarchical branch names:

feature/**

, instead of part of a branch name.
So a naming convention like:

  • ftr/or/hotfix, with pattern '*/or/*' or '**/or/**'
  • ftr_or/hotfix, with pattern 'ftr_or/**'

could work better.

like image 84
VonC Avatar answered Oct 18 '22 18:10

VonC