Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exact use of "Forbidden File path" of the Jenkins Gerrit Trigger plugin

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$ ?

like image 734
Roman Avatar asked Mar 13 '15 08:03

Roman


2 Answers

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.
like image 51
Maxim Suslov Avatar answered Nov 16 '22 01:11

Maxim Suslov


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/"

like image 2
Roman Avatar answered Nov 16 '22 00:11

Roman