8

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.

Avik
  • 723
  • 6
  • 16
  • Did you try other patterns, like '`*_ap_*`'? – VonC Dec 11 '12 at 10:06
  • @VonC Yes, I also tried `*/*_ap_*` – Avik Dec 11 '12 at 10:51
  • It might be possible that it would work only for hierarchical branch names (http://stackoverflow.com/a/2527436/6309): `feature/**`, instead of part of a branch name. Any chance to rename your branches `ftr/or/hotfix` and see if `**/or/**` works better? Or `ftr_or/hotfix`, and the pattern '`ftr_or/**`' – VonC Dec 11 '12 at 11:38
  • Umm.. I had no idea you could put "/" inside a branch name. However, changing the naming structure would involve a company wide change and isn't likely to happen. – Avik Dec 11 '12 at 11:56
  • Sure, but that would be just for a test, to see if Jenkin behaves with that kind of naming convention. You can create a branch on top of the existing branch, and then delete that new branch (without any impact to the existing branch). – VonC Dec 11 '12 at 12:00
  • @VonC I will try, but look at my edit to the question. – Avik Dec 11 '12 at 12:01
  • It seems to me that jenkins can only handle one * or ** in the expression. – Sg1team Dec 11 '12 at 12:06
  • @VonC your comment and suggestion works, I suggest turning it into an answer. Reading more comments now, I'll try again with two usages of `**` or `*` – Avik Dec 11 '12 at 12:20
  • @Sg1team and @VonC `*/or/*` worked – Avik Dec 11 '12 at 12:31

1 Answers1

8

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250