When committing to git, we mention in a comment any task from Jira by name, after which two things happen:
in GitLab the name of the task turns into an active link to it in Jira
in Jira, a comment is added to the task with links to the commit and the user who committed it, and also the text of the mention is added
Customization
We need a Jira user with write level permissions. You can use the existing one, it is important to remember that all comments in Jira when mentioning tasks from the gita will fall on behalf of this user, so it’s better to create a new one, name it, say, GitLab, and add Jira with write permissions to all your projects.
We need a GitLab user with admin rights in each of the projects that we will connect. For each project, the integration is configured separately.
In GitLab, open the project, go to Settings -> Integrations . Scroll down, we see Project services with a long list of services that can be connected.
We find in this list Jira, the form appears
Check the Active checkbox to activate the connection.
As can be seen from the form, you can separately configure the desired behavior for commits and merge-requests.
Enter your company's Web URL in Jira, for example, 'https://companyname.atlassian.net'
Jira API url - populated, if you have another Jira instance, the default URL value will be used.
The Username / Email and Password / Token fields are filled in according to whether you are using the Jira Server or the Jira Cloud. In the case of the Jira Server, you enter the Username and password of the user on whose behalf comments will be added. In the case of the Jira Cloud, you attach an email and a token that can be obtained here .
Transition ID (s) field. If you want, say, to mention a task, it automatically closes, then in this field you need to register the transition ID to the closed state. This ID can be obtained by API:
where ISSUENAME-123 is the name of a task in the desired state. You will get JSON with an array of transitions, from which you can take the desired id.
As a result, in GitLab in Settings -> Integrations Jira now has a green indicator: ')
and the Jira item will appear in the project menu, which leads to the corresponding project in Jira:
Using:
When we write a comment to a commit (no matter what tool we use to work with git), we can add the name of the tasks in text form (without quotes or any special characters like @)
bugfix XPROJECT-123, XPROJECT-124
As a result, a comment will be dropped to the corresponding task: