5

The Jenkins Gerrit Trigger Plugin has a button "Add Forbidden File path" but actually there is not too much documentation avaiable for it.
So what is the exact behavior of it?

  • Does it inhibit the trigger if one of the changed files match?
  • Or does it inhibit the trigger if all of the changed files match?
    (in other words: only matching files have changed)
  • I suppose it "overrides" a match of "Add File Path", doesn't it?
  • does it work for directory names only or down to file names?

This leads mit to the question if:
"File Path"= ^((?!_abc)(?!_def).)*$
behaves equal to:
"Forbidden File Path"= ^.*_abc$|^.*_def$ ?

Roman
  • 707
  • 8
  • 16
  • seems that there not too much Jenkins/Gerrit users around here... – Roman Apr 22 '15 at 12:25
  • I did some testing (although it's quite time consuming due to long build times) but I don't have a satisfying answer up to now. With the "File path" method I get triggers I don't want to get. With the "Forbidden File Path" method I miss triggers I want to get... – Roman Apr 22 '15 at 12:32

2 Answers2

3

One or many files

Does it inhibit the trigger if one of the changed files match? Or does it inhibit the trigger if all of the changed files match? (in other words: only matching files have changed)

According commit message trigger is inhibit if any file is matched.

This forbidden file allows the project not to trigger if any forbidden file has been impacted.

Overriding

I suppose it "overrides" a match of "Add File Path", doesn't it?

Yes. Add Forbidden file path has higher priority than Add File path.

Working for ...

does it work for directory names only or down to file names?

For both. But it is hard to add empty folder.

Question about behavior

This leads mit to the question if:

"File Path"= ^((?!_abc)(?!_def).)*$

behaves equal to:

"Forbidden File Path"= ^._abc$|^._def$ ?

Probably you made a mistake: ^((?!_abc)(?!_def).)*$ instead of ^.*(?!_abc)(?!_def)$. Because in first case you compare right from start (^) and your quantifier (*) repeats whole expression, not a ..

In second case we have a different behavior for two or more files. Because

  1. Add File path starts build if any of them found. But Add Forbidden File path inhibits build if any of file found.
  2. Also you need to fill Add File path with ** at least to start work Add Forbidden File path. Add Forbidden File path doesn't work if Add File path is empty.
Community
  • 1
  • 1
Maxim Suslov
  • 4,335
  • 1
  • 35
  • 29
  • Many thanks for this very useful answer! So (what I should have guessed) it does what it says - and the feature that would make it really comfortable for me would be named "Add Ignored File path" (but doesn't exist). I will doublecheck my regexes... – Roman Sep 15 '15 at 06:08
  • Regarding the last point ("Add File path" may not be empty): this means that the "Add Forbidden File path" doesn't inhibit any trigger if "Add File path" is empty, does ist? A very notably fact, indeed! – Roman Sep 15 '15 at 06:21
  • Regarding the regexes: I must confess that I never fully understood the negative lookahead. I did some testing on www.regexr.com but it gives me correct results with ^((?!_abc)(?!_def).)*$ – Roman Sep 15 '15 at 06:24
  • ad 2.) this should be fixed with V2.15.2 of the plugin (according to https://github.com/jenkinsci/gerrit-trigger-plugin/pull/251). So it should also work if "Add File path" is empty. – Roman Oct 08 '15 at 13:39
2

According to the docs my needs should be adressed with V2.16.0 of the Plugin (see JENKINS-30620) - the new option "Disable Strict Forbidden File Verification" should be used for this.
In the help it says:

  • Enabling this option will allow an event to trigger a build if the event contains BOTH one or more wanted file paths AND one or more
    forbidden file paths.
  • In other words, with this option, the build will not get triggered if the change contains only forbidden files, otherwise it will get triggered.

So I took a day of testing but it doesn't seem to work at my site.

But at least I got it working via the "Add File Path" parameter, thanks to the information that was postet in JENKINS-19891:

However, since the commit always contains COMMIT_MSG file, it will match the regex and triggers the build.

So I added the commit message file to my regexes which finally gives me the correct results.

Example: ^((?!\/COMMIT_MSG|cunit|_abc|_def[\/\.]).)*$
...for ignoring changes in files who's name (including path) contains any of "cunit", "_abc", "_def." or "_def/"

Roman
  • 707
  • 8
  • 16