Skip to content

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:

  1. Set up a GitLab for Jira app development environment
  2. Link a namespace
  3. Create an issue on Jira and remember the issue ID e.g. TEST-123
  4. On GitLab, create a branch named TEST-123_whatever and an MR for the branch with title TEST-123 whatever
  5. The branch and MR should show up in the side panel on the Jira issue. Screenshot_2022-06-15_at_21.57.57
  6. Create a new branch with name whatever and an MR with title TEST-123 whatever 2
  7. 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
Edited by Magdalena Frankiewicz