Shared Jenkins library which all ODS projects & components use - provisioning, SonarQube code scanning, Nexus publishing, OpenShift template based deployments and repository orchestration
Apache License 2.0
72
stars
57
forks
source link
GitService.issueIdFromCommit failing when Issue ID is not on the first line in a multiline commit message #974
Describe the bug
Some time (around 6 weeks) ago bitbucket changed the content of the automatically generated merge commit message for pull requests. My bitbucket version is now 7.21.7 .
Before:
Pull request #43: Feature/MYPROJECT-147 jenkins pipeline broken
Merge in MYPROJECT/myrepo from feature/MYPROJECT-147-jenkins-pipeline-broken to master
* commit 'b5b627a315fa9e739d81d7c38d937676d44795d7':
Now:
Pull request #49: adapt to new url
Merge in MYPROJECT/myrepo from bugfix/MYPROJECT-483-url-is-defect
* commit '0749118969654c44f400f6a3034ae3bd5bb48969':
Since this change the context.issueId in my Jenkinsfile inside the odsComponentPipeline is always empty when a pull request for a feature/bugfix branch is merged back to master.
I believe the problem is in GitService.groovy Line 44ff : The msgMatcher does not carry the multiline flag to also check subsequent lines for an issue id.
Merge pull request with a multiline commit message that has the PROJECTID-ISSUED not on the first line (as Bitbucket 7.21.7 does it automatically)
Observe output of context.issueId to be empty
Expected behavior
When merging a pull request with PROJECTID-ISSUEID somewhere in a multiline commit message context.issueId should be set accordingly.
Affected version (please complete the following information):
OpenShift: 4.11
OpenDevStack: 4.1.0 + Master
Gradle code to test regex
Remove the (?m) flag in the matcher and the regex fails.
def s = """
Pull request #50: remove
Merge in ODMC/odmc-fullstack from bugfix/MYPROJECT-484-test-pull-request-message to master
* commit '99dee286861205fcf0d5ad787ce53c69c77770bf':
remove
"""
def msgMatcher = s=~ /(?m)MYPROJECT-([0-9]+)/
if (msgMatcher) {
println("yes")
println(msgMatcher[0][1])
} else {
println("no")
}
Describe the bug Some time (around 6 weeks) ago bitbucket changed the content of the automatically generated merge commit message for pull requests. My bitbucket version is now 7.21.7 .
Before:
Now:
Since this change the
context.issueId
in my Jenkinsfile inside theodsComponentPipeline
is always empty when a pull request for a feature/bugfix branch is merged back to master.I believe the problem is in GitService.groovy Line 44ff : The
msgMatcher
does not carry the multiline flag to also check subsequent lines for an issue id.Changing the code as follows should fix the bug:
To Reproduce Steps to reproduce the behavior:
context.issueId
PROJECTID-ISSUED
not on the first line (as Bitbucket 7.21.7 does it automatically)context.issueId
to be emptyExpected behavior When merging a pull request with
PROJECTID-ISSUEID
somewhere in a multiline commit messagecontext.issueId
should be set accordingly.Affected version (please complete the following information):
Gradle code to test regex Remove the
(?m)
flag in the matcher and the regex fails.