Include related MR Jira issue keys for branches
Release notes
GitLab for Jira Cloud app will show related GitLab branches when viewing an issue in Jira, but only if the branch names contained the Jira ticket ID specifically (e.g., my-branch-JIRA-1
).
This change will associated GitLab branches with an issue in Jira, if the corresponding merge request title or description references the Jira ticket.
Problem
GitLab for Jira Cloud app will show related GitLab branches when viewing an issue in Jira, but only if the branch names contained the Jira ticket ID specifically (e.g., my-branch-JIRA-1
).
Proposed solution
This change will associated GitLab branches with an issue in Jira, if the corresponding merge request title or description references the Jira ticket.
When syncing branches with Jira we can only extract issue keys from the branch name (see lib/atlassian/jira_connect/serializers/commit_entity.rbLL11
. However, the Jira issue might be mentioned in the description or title of the related MR.
We can add an option to pass issue keys from the PullRequestEntity
down to the BranchEntity
Context
Syncing branches in this case means through the GitLab for Jira app. The problem described here can be reproduced by the following steps:
- Set up a GitLab for Jira app development environment
- Link a namespace
- Create an issue on Jira and remember the issue ID e.g. TEST-123
- On GitLab, create a branch named
TEST-123_whatever
and an MR for the branch with titleTEST-123 whatever
- The branch and MR should show up in the side panel on the Jira issue.
- Create a new branch with name
whatever
and an MR with titleTEST-123 whatever 2
- Now only the MR appears in the sidebar because the branch could not be associated with a Jira issue ID
Availability & Testing
If i'm understanding correctly, I'm thinking it could be a good idea write a spec that creates a new MR with a Jira issue key in the title/description and expect that it triggers a branch sync request with that issue key.
Suggestions:
- pending: write new examples for
sync_project_branch_spec.rb
that creates an MR with a Jira issue key in the title/description and validates that the sync was triggered with the correct request. - run
package-and-qa