Skip to content

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.

#300031 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Jira issue development panel showing deploy
image
All deployments info
image

How to set up and validate locally

  1. Set up a Jira Connect integration, using GitPod https://gitpod.io:
  2. In Jira, once your Jira Connect integration has been installed, click Get start and link the gitlab-org group that is on your GitPod instance.
  3. Enable runner on GitPod https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/gitpod.md#enable-runners
  4. Enable the feature flag. From the GitPod terminal, first start the Rails console: cd /workspace/gitlab-development-kit/gitlab && bundle exec rails c and then enable the feature flag:
    Feature.enable(:jira_deployment_issue_keys)
  5. In Jira, create two new issues, note their IDs (example: JIRA-1, JIRA-2).
  6. In your Gitpod GitLab instance, create a branch in the gitlab-org/gitlab-test project: Visit /gitlab-org/gitlab-test/-/branches and choose New branch, give it a name.
  7. 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"
  8. In the commit message, reference one of the Jira issues (example: JIRA-1).
  9. Make another change to the CI file (add a #comment) and reference another of the Jira issues (example: Jira-2).
  10. Create a last commit, and this time don't add any Jira references.
  11. In Jira, view the issues you have referenced. They should display the commits (existing feature) in their development panel sidebar.
  12. They most like all reference a GitLab "release" too (new feature) which will be pending.
  13. Go to CI pipelines page of the project /gitlab-org/gitlab-test/-/pipelines and click > and choose deploy_staging.
  14. In Jira, view the issues you have referenced. Click See all deployments on each issue to see all previous deployments. You should see the successful deployment associated with each Jira issue.
  15. 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.

Related to #300031 (closed)

Edited by Luke Duncalfe

Merge request reports