Jira is a popular issue tracking product that is widely used to facilitate agile software development. It’s backed by Atlassian’s own source control, BitBucket, which links issues directly to commits. However, you can enable the same support for Gitlab as well.
What is the integration doing?
Basically, with the Jira integration for Gitlab, you can link Jira problems with Git commits. When changes are pushed to Gitlab, it will check to see if any Jira issues are mentioned in the commit message or description and add a comment to the issue.
This is a simple feature, but it is vital to linking the two platforms together. For example, suppose you give a developer a number of issues to work on in a code sprint. This developer creates a series of commits and, when the tasks are complete, forwards them to Gitlab, mentioning issues in the process. When the project manager goes through Jira, they can quickly see the associated commits for any issue as there are links to every commit on that issue.
This also works the other way round: In Gitlab you can quickly see which problems a commit mentions. This mostly just saves you one click, but is a nice feature if you have a lot of problems.
With the integration, you can also automate the closing of issues from commit messages. If developers need to move issues from In Progress to In Review, you can configure Gitlab to do this whenever someone writes. ”
Resolves PROJECT-1”In a commit message.
The same functions are also supported for merge requests. This is useful when a developer is working on their own branch that needs to be merged with the master.
Set up the Jira integration
The Jira integration is configured for each project. So go to your project page and click “Settings”> “Integrations”:
In the “Project Services” list, scroll down to find “Jira” and click on it. You need to configure a number of things here.
First you want to activate the integration by checking “Active”. You can also turn off the requests commit and merge triggers, but you probably want those.
Next, enter your Jira web url. If you’re using the managed cloud version of Jira (on atlassian.net), enter yours
companyname.atlassian.net Url. If you’re hosting Jira yourself, enter the url to your instance, probably something like
jira.companyname.com. If you host Jira yourself and set the API to a different domain, you can optionally enter this here.
If you are using the cloud version of Jira, you will want to enter your email address and an API token which you can get on this page. Create a new token and paste it into the field in Gitlab. This will authenticate Gitlab with your Atlassian account. If you’re using self-hosted Jira, you’ll simply want to enter your username and password.
In either case, you will likely want to create a service account so that messages from Gitlab rather than your personal user account can be viewed. If you don’t want to pay an additional account, your personal account will work fine.
Next, you need to give Gitlab a list of transition IDs. These define the different phases of problems, e.g. B. “Todo”, “In Progress” and “Done”. It’s strange that Gitlab doesn’t automatically configure this, but you can get a list of them from the Jira API by going to the following url in your browser:
Note that you need to replace your actual Jira URL with “yourcompany” and enter a real problem ID in “ISSUE-1”. This will give
var x = `paste response here` console.log(JSON.parse(x).transitions.map((d)=>d.id).join(','))
Which will give something like that back
11, 21, 31 (Default setting) that you enter in the Transition ID field.
Use the Jira integration
Using the Jira integration is pretty easy. There are no check boxes or levers to pull. Just mention a Jira Issue ID anywhere in the subject or description of a commit. Gitlab automatically publishes a comment on the problem, which leads back to the commit page:
That’s fine and all, but it’s even better to be able to close problems out of commits. There are currently three trigger words that you can use to conclude an issue:
- Fixes PROJEKT-1
- Closes PROJECT-1
- Fixes PROJECT-1
You can write these inline in commit messages or descriptions:
Each of them do the same thing: move the related issue to the last transition ID you provided in the list. If you don’t want developers to push issues straight to Done, you can configure Gitlab to send commits to In Review by omitting the transition IDs for the unwanted categories.