jenkinsci / jenkinsci/gerrit-trigger-plugin
[JENKINS-19891] When configuring Gerrit project with file pattern, do not try to match COMMIT_MSG file.
- Dominant language
- Java
- Stars
- 226
- Forks
- 289
- PR merge metrics
- No merged PRs in 30d
Description
Description:
I need to trigger a build only when a file in a specific directory is modified. When I configure regex with negative lookaround, it does not work in current situation.
Example:
Given there is a following directory structure:
.
-module1
---src
-----main
-------java
-module2
---src
-----main
-------java
-module3
-module4
... a lot more modules ...
When I make change in module1 only
Then I do not want to trigger a build.
Currently, the gerrit trigger plugin iterates over list of all modified files in commit, and tries to do a regex match.
When I configure the regex as: "^((?!module1).)*$", it matches any file that does not start with "module1" string.
However, since the commit always contains COMMIT_MSG file, it will match the regex and triggers the build.
When we tried opposite approach, we run into a problem - since there are too many modules in the project, it would be very complicated and prone to error to list all paths that should trigger the build.
It is either solvable as a modified regex pattern, ie "^((?!module1|\/COMMIT_MSG).)*$" , however it would be IMO more sane to omit the COMMIT_MSG file from checking. Proposed patch is attached.
---
Originally reported by
gerza, imported from: When configuring Gerrit project with file pattern, do not try to match COMMIT_MSG file.
rsandell
Raw content of original issue
Description:
I need to trigger a build only when a file in a specific directory is modified. When I configure regex with negative lookaround, it does not work in current situation.Example:
Given there is a following directory structure:
.-module1
---src
-----main
-------java
-module2
---src
-----main
-------java
-module3
-module4
... a lot more modules ...
When I make change in module1 only
Then I do not want to trigger a build.Currently, the gerrit trigger plugin iterates over list of all modified files in commit, and tries to do a regex match.
When I configure the regex as: "^((?!module1).)*$", it matches any file that does not start with "module1" string.
However, since the commit always contains COMMIT_MSG file, it will match the regex and triggers the build.When we tried opposite approach, we run into a problem - since there are too many modules in the project, it would be very complicated and prone to error to list all paths that should trigger the build.
It is either solvable as a modified regex pattern, ie "^((?!module1|\/COMMIT_MSG).)*$" , however it would be IMO more sane to omit the COMMIT_MSG file from checking. Proposed patch is attached.
1 attachment
- [0001-Disable-matching-COMMIT_MSG-file.patch](https://issues.jenkins.io/secure/attachment/24479/0001-Disable-matching-COMMIT_MSG-file.patch)
Contributor guide
Assessment
This issue has not been assessed yet.