Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitService.issueIdFromCommit failing when Issue ID is not on the first line in a multiline commit message #974

Open
mariussl opened this issue Feb 17, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mariussl
Copy link

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.

Changing the code as follows should fix the bug:

def msgMatcher = commitMessage =~ /(?m)${uppercaseProject}-([0-9]+)/

To Reproduce
Steps to reproduce the behavior:

  1. Create a bugfix/feature branch
  2. Change something
  3. Create a pull request
  4. Edit Jenkinsfile to output context.issueId
  5. 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)
  6. 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")
}
​
@mariussl mariussl added the bug Something isn't working label Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant