Fix SyncMergeRequestWorker problems due to branch
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
Screenshots or screen recordings
Screen_Recording_2023-04-14_at_9.33.00_PM
How to set up and validate locally
Setting up GitPod
- Sign up for Jira https://www.atlassian.com/software/jira
- Set up a GitLab for Jira app development environment using GitPod.
- In GitPod:
- Open port
3000
- 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)
- Create an issue on Jira and note the Jira issue ID e.g.
TEST-1
. - In GitLab, create a new MR that has the Jira issue ID in the title or description.
- In the Jira issue, you should see the MR associated. Sometimes with GitPod, this can be delayed.
- In GitLab, close the MR.
- In the Jira issue, you should see the MR status be
closed
. Sometimes with GitPod, this can be delayed.
QA with the flag enabled
- 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)
- Create an issue on Jira and note the Jira issue ID e.g.
TEST-2
. - In GitLab, create a new MR that has the Jira issue ID in the title or description.
- In the Jira issue, you should see the MR associated. Sometimes with GitPod, this can be delayed.
- In GitLab, close the MR.
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #354373 (closed)