Extract Jira issue keys for deploy from commits
What does this MR do and why?
This MR extracts Jira issue keys to associate with a GitLab deploy from all the commits (up to a limit) made on the branch since the last successful deployment to that environment.
See #300031 (comment 1431741254) for a detailed explanation.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Jira issue development panel showing deploy |
|---|
![]() |
| All deployments info |
|---|
![]() |
How to set up and validate locally
- Set up a Jira Connect integration, using GitPod https://gitpod.io:
- In Jira, once your Jira Connect integration has been installed, click Get start and link the
gitlab-orggroup that is on your GitPod instance. - Enable runner on GitPod https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/gitpod.md#enable-runners
- Enable the feature flag. From the GitPod terminal, first start the Rails console:
cd /workspace/gitlab-development-kit/gitlab && bundle exec rails cand then enable the feature flag:Feature.enable(:jira_deployment_issue_keys) - In Jira, create two new issues, note their IDs (example:
JIRA-1,JIRA-2). - In your Gitpod GitLab instance, create a branch in the
gitlab-org/gitlab-testproject: Visit/gitlab-org/gitlab-test/-/branchesand choose New branch, give it a name. - In the branch add the following CI file, it must be named
.gitlab-ci.yml:deploy_staging: stage: deploy when: manual script: - echo "Deploy to staging server" environment: name: staging url: https://staging.example.com variables: GIT_LFS_SKIP_SMUDGE: "1" deploy_production: stage: deploy when: manual script: - echo "Deploy to production server" environment: name: production url: https://example.com variables: GIT_LFS_SKIP_SMUDGE: "1" - In the commit message, reference one of the Jira issues (example:
JIRA-1). - Make another change to the CI file (add a
#comment) and reference another of the Jira issues (example:Jira-2). - Create a last commit, and this time don't add any Jira references.
- In Jira, view the issues you have referenced. They should display the commits (existing feature) in their development panel sidebar.
- They most like all reference a GitLab "release" too (new feature) which will be pending.
- Go to CI pipelines page of the project
/gitlab-org/gitlab-test/-/pipelinesand click>and choosedeploy_staging. - In Jira, view the issues you have referenced. Click
See all deploymentson each issue to see all previous deployments. You should see the successful deployment associated with each Jira issue. - Note that Jira displays the first (oldest) deployment in the Releases section of the issue and all deployments when you click
See all deployments. This is quirky, but is Jira functionality #300031 (comment 1433009083).
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 #300031 (closed)
Edited by Luke Duncalfe

