Skip to content

Fix SyncMergeRequestWorker problems due to branch

Luke Duncalfe requested to merge 354373-bugfixes into master

What does this MR do and why?

!115448 (merged) added a change that sends through branch data to Jira alongside the merge request data.

It introduced 2 bugs, one when the flag was disabled, and one when it was enabled.

This line where we add the associated branch to the sync needed to be wrapped in the feature flag too.

When the flag was disabled, we were sending Jira a branch that had no Jira reference refs (unless the branch specifically had the Jira issue reference in its name), and Jira then would reject the whole request.

When the flag is enabled, the branch does include Jira issue refs.

When enabled, there was a bug where closing a merge request would not update the merge request's status in Jira. This was because we only select open merge requests to send through within the branch Jira issue references, and if the merge request was closed, this would lead to the request being rejected by Jira for similar reasons as above.

This change:

  • Sends nil branches when jira_include_keys_from_associated_mr_for_branch flag is disabled
  • Sends nil branches when the merge request is not open

#354373 (closed)

Screenshots or screen recordings

Screen_Recording_2023-04-14_at_9.33.00_PM

How to set up and validate locally

Setting up GitPod

  1. Sign up for Jira https://www.atlassian.com/software/jira
  2. Set up a GitLab for Jira app development environment using GitPod.
  3. In GitPod:
  4. Open port 3000
  5. Change to this branch, on the GitPod terminal:
cd /workspace/gitlab-development-kit/gitlab &&
git fetch origin 354373-bugfixes &&
git checkout 354373-bugfixes &&
bundle &&
yarn &&
cd /workspace/gitlab-development-kit &&
gdk restart

QA (with the flag disabled)

  1. Create an issue on Jira and note the Jira issue ID e.g. TEST-1.
  2. In GitLab, create a new MR that has the Jira issue ID in the title or description.
  3. In the Jira issue, you should see the MR associated. Sometimes with GitPod, this can be delayed.
  4. In GitLab, close the MR.
  5. In the Jira issue, you should see the MR status be closed. Sometimes with GitPod, this can be delayed.

QA with the flag enabled

  1. Enable the flag
    # In GitPod, start the rails console from the GitPod terminal:
    cd /workspace/gitlab && bundle exec rails c
    Feature.enable(:jira_include_keys_from_associated_mr_for_branch)
  2. Create an issue on Jira and note the Jira issue ID e.g. TEST-2.
  3. In GitLab, create a new MR that has the Jira issue ID in the title or description.
  4. In the Jira issue, you should see the MR associated. Sometimes with GitPod, this can be delayed.
  5. In GitLab, close the MR.
  6. In the Jira issue, you should see the MR status be closed. Sometimes with GitPod, this can be delayed.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #354373 (closed)

Edited by Luke Duncalfe

Merge request reports