Excluding some folders from build trigger
Asked by Phillip Martin:

Short question:

What expression should I use to stop builds triggering when a subset of folders change, when using bamboo on windows, with mercurial.

Long version:

I am having a bit of trouble getting the Include / Exclude files option to work the way I want it to.

The feature I'm talking about is in Plan Configuration \| Source Repositories \| \<your repo\> \| Advanced Options \| Include / Exclude Files

I am using mercurial and have this source layout:

* libraries/
* products/
  * ProductA/
  * ProductB/

In the plan for ProductA, I have the "Excliude all changes that matches to" chosen, with the following file pattern:

\^products/(?!ProductB)/.\*

I am unsure how to go about debugging it. I can't find any log files that show what regular expressions were used, and what filenames were given to it.

I guess the core questions are:

1. Are relative or absolute paths given to the regular expression
2. Are windows or unix paths given (i.e. forward or back slashes)
3. Is file exlcusion supported with mercurial.

Thanks for your help,

Phil Martin


Answers:
author: Phillip Martin
body: I found the problem. It was, as usual, a regex issue.

I forgot that the ?! is a zero width assertion, and does not match. That means that even though it correctly ignored ProductB, the remainder of the regex did not match, so nothing passed.

The correct regex is \^products/(?!ProductB).\*

That means that once the assertion is satisfied, match anything after products/

Everything is workign now, thanks for your help Piotr. The debugging tips will come in very handy in the future


author: PiotrA
body: Hm... So maybe it would be easier to set up "include filter" instead of "exclude filter". Like for example you could use regexp that would match libraries/.\* and products/ProductX/.\* (I don't remember at the moment how do you do the "and" in regexp world, but I'd cut a hand that it is possible).

Anyway, with the 'exclude filter' I'd try following:

\^products/ProductX/.\*

Isn't that working?


author: PiotrA
body: Yeah, I can confirm that \^products/(?!ProductB)/.\* won't work. But please note that this is a different regexp than plain \^products/ProductB/.\* - at least my debugger was seeing enough difference to return different match value when I was testing against "products/ProductB/src.txt" file committed to my test repo.

Anyway, good luck with starting this up again - me logging off.

good night! :)


author: Phillip Martin
body: My current regexp \^products/(?!ProductB)/.\* isn't working, or at least it didn't seem to.

I'm just starting everything up and I'll try and variety of regular expressions, and also the include filters, and get back to you.

Thanks for the prompt replies!


author: Phillip Martin
body: Thanks for the query Piotr. Yes you are right.

Say I had seven independant products, and I had seven build plans, I want each plan to build when any change is made anywhere in the source code that ISN'T in the other products.

I'm not certain this is the way I will end up structuring the source/plan structure, but it is what I'm evaluating at the moment.


author: PiotrA
body: Hi,

as for your questions:

1) I believe the relative (to the repository root) paths are given to the regexp, so for example the match will be run against "product/ProductB/src.txt", not some "/product/ProductB/src.txt" nor "/home/Bamboo/blablabla/product/ProductB/src.txt".  
2) Good question. I believe unix ones are used, the ones returned from hg command. What do you see in the 'changes' tab in your Bamboo build results? Forward, or back slashes?  
3) Yes, definitely.  

As for the debugging - you might try to increase log level to DEBUG for the com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager class (use Bamboo-\>Administration to do that withour restarting Bamboo) and then you might get more verbose logs in the atlassian-bamboo.log. But I'm not sure if they will be much valuable - they will only log fileName matches (if they happen).

Is that helpful?

regards,


author: PiotrA
body: Hello Phillip,

May I ask you what are you trying to achieve? I mean - which changes do you want to exclude? Do you want your Bamboo to trigger builds whenever something changes in your repo on other paths than the "products/ProductB"?