Branch Specification Wildcard Syntax (Git)

Answered

What syntax is available to me to be able to filter the branches in the Branch Specification?

My branches are mostly named like....

 refs/heads/main-feature

...but there are some like...

 refs/heads/main-featureX-blah

I want to include the branches like the first example, but the not the ones like the second, but with only one '*' wildcard allowed I don't seem to be able to do that. e.g.

+:refs/heads/main-feature*

...is kind of ok as a start, but I then want to further exclude branches with the second '-', something along the lines of...

-:refs/heads/main-feature*-*

...but that doesn't seem to be possible because I can only use one '*' wildcard.

5 comments

Hi Gavin,

Will the following setup work for you:

+:refs/heads/main-feature
-:refs/heads/main-feature*

If not, please provide an example.

0

Ah, sorry, my example was not so clear.  There are many feature branches which I want to include, but the names follow a pattern e.g.

 refs/heads/main-featureX

 refs/heads/main-feature

So I would have hoped to pick them up with the wildcard,  But sometimes there are further branches which I want to exclude...

 refs/heads/main-featureX-someOtherStuff

 refs/heads/main-featureY-someOtherStuff

 

 

 

 

 

 

 

 

 

0

Hello Gavin,

Thank you for provided examples. Wildcards are also used to extracts the branch name to be displayed in the TeamCity interface (logical branch name) and several wildcard or more complex regexps are not supported.

I would suggest you to change branch naming or try to use separate build configurations. Another option is to check branch in the first build step and finish build if needed, but it's not recommended approach.

0

Thanks Alina. 

 

For the moment we have chosen to add '-CI' suffix to the branches we want to be picked up by TeamCity.  We can then use a selector like...

+:refs/heads/main-(*)-CI

Not totally happy with it, but it means we can choose what to include by just adding that suffix to the file name.

 

Is there any technical reason why multiple wildcards are not supported?  I notice the source of the git plugin is available online.  Is there any reason I couldn't fork that and extend the filter syntax?

 

0

Hello Gavin,

I do not think that there are any technical reasons, the only thing that should be kept in mind is that part matched by * becomes name of the branch.

Just yesterday the same feature was requested in our tracker: https://youtrack.jetbrains.com/issue/TW-45417, please watch/vote for it.

0

Please sign in to leave a comment.