jenkinsci / jenkinsci/git-plugin
[JENKINS-64656] Polling: Pattern for excluded messages doesn't match due to final line break
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
- add a message "Polling ignores commits with certain messages"
.*\[maven-release-plugin\].*
- commit with this message - polling doesn't ignore the message
- Reason: the commit message string contains a final line break (commits I created locally, commits that are created on Jenkins host with CentOS)
- Analysis: I added some lines with listener.getLogger().println("[ABC] ...") to src/main/java/hudson/plugins/git/extensions/impl/MessageExclusion.java
- Polling Log showed me that the message contains a line break that doesn't match with pattern - empty line in polling log:
[ABC] Checking commit 4b22f7aacbf22359c46adbdf20b04c09cf8b890e: Found message [maven-release-plugin]
[ABC] >> excludedMessage: [.*\[maven-release-plugin\].*]
[ABC] >>>> Pattern IS set: .*\[maven-release-plugin\].*
[ABC] >> acceptedMessage: [[maven-release-plugin]
]
- Fix: I changed the following line in src/main/java/hudson/plugins/git/extensions/impl/MessageExclusion.java:
// old line that doesnt ignore the message
excludedPattern = Pattern.compile(excludedMessage);
// new line that works with the final line break
excludedPattern = Pattern.compile(excludedMessage, Pattern.DOTALL);
As I'm not a software developer, I'm not sure about side effects when adding Pattern.DOTALL to the code line I mentioned - but it works for me with simple patterns like .[maven-release-plugin].
---
Originally reported by carstensteinchen, imported from: Polling: Pattern for excluded messages doesn't match due to final line break
Raw content of original issue
- add a message "Polling ignores commits with certain messages"
.*\[maven-release-plugin\].*
- commit with this message - polling doesn't ignore the message
- Reason: the commit message string contains a final line break (commits I created locally, commits that are created on Jenkins host with CentOS)
- Analysis: I added some lines with listener.getLogger().println("[ABC] ...") to src/main/java/hudson/plugins/git/extensions/impl/MessageExclusion.java
- Polling Log showed me that the message contains a line break that doesn't match with pattern - empty line in polling log:
[ABC] Checking commit 4b22f7aacbf22359c46adbdf20b04c09cf8b890e: Found message [maven-release-plugin][ABC] >> excludedMessage: [.*\[maven-release-plugin\].*]
[ABC] >>>> Pattern IS set: .*\[maven-release-plugin\].*
[ABC] >> acceptedMessage: [[maven-release-plugin]
]
- Fix: I changed the following line in src/main/java/hudson/plugins/git/extensions/impl/MessageExclusion.java:
// old line that doesnt ignore the message
excludedPattern = Pattern.compile(excludedMessage);
// new line that works with the final line break
excludedPattern = Pattern.compile(excludedMessage, Pattern.DOTALL);
As I'm not a software developer, I'm not sure about side effects when adding Pattern.DOTALL to the code line I mentioned - but it works for me with simple patterns like .[maven-release-plugin].
- environment:
GIT Plugin 4.5.2, Jenkins 2.222.4
Contributor guide
Assessment
This issue has not been assessed yet.