Logo

dev-resources.site

for different kinds of informations.

Bridging Jira and GitLab: Automating CI/CD Pipelines for Releases

Published at
8/25/2024
Categories
cicd
jira
gitlab
devops
Author
maxim_radugin
Categories
4 categories in total
cicd
open
jira
open
gitlab
open
devops
open
Author
13 person written this
maxim_radugin
open
Bridging Jira and GitLab: Automating CI/CD Pipelines for Releases

Introduction

Jira Cloud and GitLab are popular productivity and DevOps platforms widely used by many organizations and software development teams. While the integration between these platforms has significantly improved in recent years, there are still areas in common software development tasks that require manual effort or custom integration solutions.

One such area is software releases. In this post, I will demonstrate how to streamline and automate this process, it will be useful for teams who:

  • Plan and manage tasks in Jira;
  • Use Jira versions for planning product milestones and releases;
  • Keep their source code in GitLab;
  • Use GitLab's CI/CD pipelines for deploying and releasing products.

User Story

As a Release Manager, I want GitLab to automatically trigger a release CI/CD pipeline when I change a Jira version's status to 'Released' and its name matches a specific format (e.g., 'v1.2.3'), so that release information is immediately synchronized between Jira and GitLab, reducing manual work and potential errors.

Implementation

To make this happen, we need to:

  • Set up Jira to trigger an action when a version is released.
  • Use the GitLab API to create a matching tag in git repository.
  • Configure GitLab CI/CD to run a release or deploy job when this tag is created.

We'll go through these steps in detail for both Jira and GitLab. This guide uses GitLab's cloud version, but the process is similar for self-hosted GitLab instances.

GitLab Configuration

Create Personal Access Token

You can skip this step if you already have a Personal Access Token (PAT) with the api scope that you can reuse. If not, follow these steps:

  1. In GitLab, navigate to your preferences by clicking on your avatar icon, then Preferences -> Access tokens
  2. Click Add new token, enter a token name (e.g., Jira Release Automation), extend the expiration date, and select the api scope GitLab PAT configuration
  3. Press Create personal access token and note down the token value GitLab PAT created

Modify CI/CD Configuration

In your GitLab project, add the following rule to the release job in your .gitlab-ci.yml file. This ensures the job is triggered only for git tags with a vX.Y.Z format, where X, Y, Z are non-negative integers:

rules:
  - if: '$CI_COMMIT_TAG =~ /^v([0-9]+)\.([0-9]+)\.([0-9]+)$/'
Enter fullscreen mode Exit fullscreen mode

You can find a full example of the .gitlab-ci.yml file here.

Jira Project Configuration

We'll use Jira's built-in Automation to trigger the release pipeline by creating "release" tag in the desired GitLab project:

  1. From the project sidebar, select Automation -> Create rule.
  2. In the rule editor, add a trigger: Version released. Expand More options and set Version name filter to ^v([0-9]+)\.([0-9]+)\.([0-9]+)$. Version released trigger configuration
  3. Press Next, then on the workflow press Add component. Select THEN: Add an action, and add the Send web request component.
  4. Configure the Send web request component:

    • In Web request URL, enter https://gitlab.com/api/v4/projects/<group>%2F<project name>/repository/tags, replacing <group> with your GitLab group and <project name> with your actual project name. If you wonder what %2F is - it is url-encoded value of / character. In my case final URL is https://gitlab.com/api/v4/projects/radugin.com%2Fjira-gitlab-release-automation/repository/tags;
    • Leave HTTP method as POST;
    • Set Web request body to Custom data;
    • Set Custom data to:

      {
          "tag_name": {{version.name.asJsonString}},
          "ref": "main",
          "message": {{version.description.asJsonString}}
      }
      

      This request will create a new tag in specified GitLab repository, Jira version name will be used as a tag name, tag will be created from branch specified in ref (usually main or master), tag message will be populated from Jira version description field.

    • In Headers, add a hidden PRIVATE-TOKEN with your GitLab PAT value.

    Send web request action configuration

  5. Press Next, then Turn on rule. Enter a Rule name (e.g., GitLab Release Automation), and click Turn on rule again.

Verifying Automation

From Jira

  1. Create a version, for example, v1.0.0, add version description.
  2. Perform a version release.
  3. Navigate to Automation -> Audit log and verify that the rule execution was successful. Automation audit log

From GitLab

  1. Navigate to the Tags section and observe the newly created tag. GitLab tags view
  2. Click on the โœ… next to the tag to open the pipeline view, and verify that the release job (in current example - deploy job) was created. GitLab pipelines view

Conclusion

This integration represents a step towards automating and streamlining the release management process for teams using GitLab and Jira, as it bridges an important gap in the DevOps workflow.
The benefits of this automation include:

  • Reduced manual effort in managing releases;
  • Improved synchronization of release information between Jira and GitLab;
  • Decreased likelihood of errors in the release process;
  • Enhanced traceability of releases from project management to code deployment.

While the setup requires some initial configuration, the long-term benefits in efficiency and reliability make it a valuable addition to any team's automation toolset.

Related Materials

jira Article's
30 articles in total
Favicon
Jira Configuration Made Easy: First Time Tips for New Project Managers!
Favicon
Diving into the Use of Use Cases in JIRA๐ŸŒŸ
Favicon
Jira Issue Types Link to Assets
Favicon
Jira Automation Streamlines Asset Management Workflow
Favicon
Suggested Jira setup for software engineering projects
Favicon
OMZ: Some Plugins that I forget about
Favicon
Disable keyboard shortcuts for Jira and Confluence
Favicon
Jira Story Creation Template For Front End Developer
Favicon
An Overview of Jira Asset Management Tool
Favicon
Seamlessly Create Jira Issues from GitHub Using Natural Language and Supercog
Favicon
Draft: Jira API withย React
Favicon
Bridging Jira and GitLab: Automating CI/CD Pipelines for Releases
Favicon
How to integrate k6 with Xray/Jira
Favicon
How to Maintain Issue Hierarchy Between Jira and Azure DevOps
Favicon
How To Sync Epics between Two Jira Instances
Favicon
Estudos em Quality Assurance (QA) - Jira: O Bรกsico de Gerenciamento de Issues
Favicon
Everything You Need to Know about Being a Jira Administrator ๐Ÿ’ป
Favicon
What's New in AssetIT 1.4.5-AC? ๐Ÿš€
Favicon
I Used to Hate Writing Jira Tickets, Before I Start Doing This
Favicon
Connecting ServiceNow to Jira
Favicon
How to track your Jira todos and accomplishments
Favicon
All Paths Lead To Jira
Favicon
Jira Software, Jira Service Management, Jira Work Management Explained โ€“ Unlock The Full Jira Potential For Your Team
Favicon
Jira inventory management: How to categorize your assets in a service ticket?
Favicon
Whatโ€™s New in AssetIT version 1.4.3 for Cloud?
Favicon
5 Best Inventory Management Softwares in Jira 2024
Favicon
What Sets Jira Asset Management Cloud Apart From Traditional ITAM?
Favicon
Leveraging Tools to Enhance Collaborative Efficiency
Favicon
Top 5 Free Asset Management Software Solutions for Jira in 2024
Favicon
How Jira ITSM Empowers Remote Workflow | ITSM Insight

Featured ones: