Integrate GitLab.com with Jira Cloud
GitLab introduced personal access tokens (PAT) since version 8.8 and now (v10+) prefers this type of authentication for accessing the git repositories. Service users are strongly advised to switch from using username/password to using Personal Access Tokens (PAT) for GitLab.com.
Quickly learn how to connect GitLab.com git repositories via Git Integration for Jira Cloud app.
What’s on this page:
- Integrate GitLab.com with Jira Cloud
- Permissions
- Creating a personal access token
- Automatic token rotation
- Using Git service integration
- Single git repository integration
- Setting up GitLab web links
- Viewing git commits in Jira Cloud
- Working with branches and merge requests with GitLab
- Default branch
- Creating branches
- Creating merge requests
- More Integration Guides
(Updated video coming soon)
Permissions
GitLab can have users with different access level to a group or project. If the user’s connected GitLab repositories to Jira are not accessible or commits are not showing for that user — it’s related to permission issues. This can be a per user, repository or a project level restriction.
If you encounter access permission issues, you will need to ask your Git administrator to grant you the required level of access to specific projects. If you are a Git administrator, you will need to setup a GitLab user with the minimum required permissions to view GitLab projects from Jira.
Take the following cases for example:
-
The personal access token (PAT) that the GitLab user provided doesn’t have the correct permissions within GitLab to view source code for specific repositories.
-
The GitLab user doesn’t have access privileges to a GitLab repository or is not a member of a group that has access to specific repositories.
We recommend creating a specific GitLab user for the integration. This way, the GitLab user can have specific permissions to do the given tasks.
For minimum access (read-only) permissions:
-
Set the user account profile’s PAT scope to
read_repository
. -
The GitLab user is set to only read a specific repository. Set to Reporter role.
This level of access allows the user to view commits for the specific repository.
For users who will be tasked with creating branches and merge requests:
-
Set the user account profile’s PAT scope to
api
. -
The GitLab user should be set to read/write access for the specific repository. Set to Developer role.
This level of access allows the user to create/delete branches and create merge requests.
For more information, see GitLab Permissions ».
Creating a personal access token
There are several Gitlab token types:
While instructions from GitLab works just fine, follow this article for a quick step-by-step guide to get you started.
Starting May 14, 2024, Gitlab is removing support for non-expiring personal access tokens (PATs) where all existing unlimited tokens will suddenly expire. To maintain integration connections with your GitLab repositories, create a new token and manually enter it into the corresponding field in the integration connection properties in Git Integration for Jira app (GIJ).
Automatic token rotation
GIJ can automatically rotate tokens but we still encourage users to manually enter their tokens before or as soon as it expires.
The automatic rotation occurs only for the tokens used to connect Gitlab integrations. Any user PATs (used to create PRs) for Gitlab integrations aren’t automatically rotated, and must be manually updated by each user themselves.
Using Git service integration
This process requires an existing GitLab.com account. Multiple git repositories in a GitLab.com account will be connected via Git Integration for Jira Cloud app.
While instructions from GitLab works just fine, here are some specific instructions to get you up and running.
We recommend using the Git service integration panel1 to connect multiple repositories from your GitLab.com account.
-
On your Jira Cloud dashboard menu, go to Apps ➜ Git Integration: Manage integrations.
-
On the Manage integrations page, click Add integration.
-
For the following screen, click GitLab.com to start integration with this git service.
-
On the following screen, click on the Git service integration panel for your integration type.
-
For this guide, click on the OAuth integration to select it.
-
We recommend the OAuth integration which is outlined like a setup wizard — making it more easier for users to connect GitLab integrations.
-
For PAT integration, use personal access tokens (PAT) to setup your GitLab integrations. Users will have to configure their own PAT from GitLab to use for this setup.
-
For GitLab webhook indexing integration, see this article instead.
-
Configuring the Advanced settings is optional. However, admins/power users may set how the project listing is displayed. These settings are used with integration to retrieve the list of tracked repositories. Set a filter that will only load some cloned repositories which can be viewed in the Manage repositories page.
-
Custom API Path – this is a relative path that starts with “/”. The maximum allowed length is 2000 characters or less. The integration will use the relative REST API path to retrieve the list of tracked repositories.
For more information on GitLab custom API paths, see GitLab API.
For more examples, see article Jira Cloud: Working with Custom API Path.
GitLab version API support: ------------------------------------------- Gitlab v9.5 and above -- only API v4.
Remember:
The GitLab.com API can see all the public projects. For GitLab.com, we recommend using JMESPath over the Custom API path when possible. -
JMESPath filter – JMESPath is a query language for JSON used to filter API results and to limit which repositories are integrated. The maximum allowed length is 2000 characters or less.
Read about JMESPath expressions on their website. For help with writing expressions, please contact support.
To learn more examples, see article Jira Cloud: Working with JMESPath Filters.
-
-
While Custom API Path and JMESPath filter are mutually exclusive, you can use one, the other, both or neither.
-
-
Click Connect to GitLab.com to proceed to the next step.
-
Sign in to your GitLab account, if prompted. When connecting to your GitLab account using OAuth for the first time, the user will be presented with a grant authorization screen.
-
Grant organization access to a group to also have its repositories listed in the Manage repositories page.
-
IMPORTANT If access is not granted, the repositories within those organizations (and even the orgs themselves) will not show up in the Git Integration for Jira app repositories list. The only way to see these repos/orgs is to return to the GitLab web portal using admin interface and specifically grant such permissions (Profile settings ➜ Developer settings ➜ OAuth Apps).
-
Below are the differences between the three authentication options for GitLab:
Authentication Method When are group repositories connected? ---------------------------------------------------------------------------- OAuth Users should press "Authorize" on the grant authorization screen. ---------------------------------------------------------------------------- PAT Group repositories are connected immediately. ---------------------------------------------------------------------------- Username/Password Group repositories are connected immediately.
-
Click Authorize… to continue.
-
-
On the following screen, the Git Integration for Jira app will read all available repositories from your GitLab account.
-
Repositories of the logged-in GitLab user can be automatically connected to Jira Cloud. Repositories that are added or removed from GitLab will be likewise connected or disconnected from Jira Cloud.
-
Use the search options to filter displayed repositories for the current screen.
-
Connect all repositories and organizations or select specific repositories to connect for this integration.
-
-
Click Connect repositories to complete this setup.
The GitLab.com git repositories are now connected to Jira Cloud.
There will be a slight delay in adding 2FA-enabled repositories compared to others. These will show in the git configuration list eventually.
If you need to require users PAT for creating branches or merge requests, turn on this setting via the selected integration in Manage integrations page ➜ Actions ➜ Edit integration** ➜ Feature settings.
Single git repository integration
This process requires an existing GitLab git repository. Look for the the GitLab repository clone URL on the repository project page. Choose between SSH or HTTPS.
Use this information to connect the GitLab git repository to your Jira Cloud via Git Integration for Jira app:
Single git repository integration (HTTPS)
Single git repository integration (SSH)
There will be a slight delay in adding 2FA-enabled repositories compared to others. These will show in the git configuration list eventually.
Setting up GitLab web links
The Git Integration for Jira app automatically configures web linking for GitLab git repositories.
For single repository connections, web link setup is optional. However, git links will become available in Git Commits tab when configured.
For more information on this feature, see Documentation: Web linking.
Viewing git commits in Jira Cloud
-
Perform a git commit by adding the Jira issue key in the commit message. This action will associate the commit to the mentioned Jira issue.
-
Open the Jira issue on your Jira instance.
-
Scroll down to the Activity panel then click the Git Commits tab.
-
Click View full commit to view the code diff.
For more information about this feature, see Documentation: Linking git commits to Jira issues.
Working with branches and merge requests with GitLab
This process requires a GitLab git repository and a PAT with api
scope.
For GitLab Group, the user must have the Write permissions and the api
PAT scope.
Default branch
Most git integrations allow changing of the default branch of the repository/project other than “master”. This change is reflected in the Repository Settings of the Git Integration for Jira app on the next reindex. Full feature integrations support this function where Git Integration for Jira app gets the default branch from almost all integrations and apply this setting at repository level.
Creating branches
On your Jira Cloud instance, open a Jira issue. On the Jira Git integration development panel, click Open Git integration then click Create branch. The following dialog is displayed.
Pointers:
-
Select a Repository from the list.
-
The git host service logo is displayed for all the repositories in the dropdown list to easily identify which git service they belong.
-
If there are several repositories with the same name, the listed GitLab repositories will have their names attached with a GitLab owner name. For example,
johnsmith/second-webhook-test-repo
. -
Use the search box in the dropdown list to filter displayed repositories.
-
OPTIONAL Designate the repository to be the default selected repository for current Jira project. To configure default repositories for more than one Jira project – use the User settings page.
-
-
Choose a Source branch. OPTIONAL Designate the branch to be the default selected branch for the currently selected repository. To configure default branches for more than one connected repository – use the User settings page.
-
Enter a Branch name or leave it as is (recommended).
-
Click Create branch to complete this process.
The newly-created branch is now listed in the developer panel under Branches. Perform a commit to the newly-created branch to be ready for merge.
Creating merge requests
The merge request feature works the same as merge request. On your Jira Cloud, open the Jira issue where your previously created a branch. On the Jira Git integration development panel, click Open Git integration then click Create merge request. The following dialog is displayed.
Pointers:
-
Select a Repository from the list.
-
The git host service logo is displayed for all the repositories in the dropdown list to easily identify which git service they belong.
-
If there are several repositories with the same name, the listed GitLab repositories will have their names attached with a GitLab group name. For example,
BigBrassBand/second-webhook-test-repo
. -
Use the search box in the dropdown list to filter displayed repositories.
-
OPTIONAL Designate the repository to be the default selected repository for current Jira project. To configure default repositories for more than one Jira project – use the User settings page.
-
-
Choose the newly-created branch as the Source branch.
OPTIONAL Designate the branch to be the default selected branch for the currently selected repository. To configure default branches for more than one connected repository – use the User settings page.
-
Set master as the Target branch.
-
Enter a descriptive Title or leave it as is (recommended).
-
Click Create pull request to complete this process. Follow the link to the PR to setup for review and approval.
The merge request is listed on the developer panel of the Jira issue page.
The merge request is also ready for approval by the reviewers in your GitLab web portal.
More Integration Guides
GitHub.com (Git Integration for Jira Cloud)
GitHub Enterprise Server (Git Integration for Jira Cloud)
GitLab.com (this page)
GitLab CE/EE (Git Integration for Jira Cloud)
Azure DevOps | Visual Studio Team Services (VSTS) (Git Integration for Jira Cloud)
Azure DevOps Server | Team Foundation Services (TFS) (Git Integration for Jira Cloud)
AWS CodeCommit (Git Integration for Jira Cloud)
Gerrit (Git Integration for Jira Cloud)
Bitbucket Cloud (Git Integration for Jira Cloud)
Introduction to Git integration (Git Integration for Jira Cloud)
All product names, logos, and brands are property of their respective owners.