Integration Guide

gitlab server logo GitLab Server EE/CE Integration1 Jira Server

Introduced in v2.9.4 of the Git add-on, this feature tracks added or deleted repositories from a remote GitLab server (EE/CE) and automatically imports those Git repository references into Jira.

GitLab v10+ stopped accepting username/password credentials for API access and will only recognize Personal Access Tokens (PAT) and OAuth authentications.  Service users are strongly advised to switch from using username/password for newer versions of GitLab Server (CE/EE) to using PAT.

For GitLab Server service users, they won't see the issue until they upgrade their GitLab Servers to version 10 and higher.  Git Integration for Jira add-on offers pre-v10 GitLab Server service users as a Legacy connection option.

helpful tips
BigBrassBand recommends a dedicated user for this integration which has access permissions to the GitLab git repositories.

Connecting to a GitLab Server Jira Server

This process requires an existing GitLab Server EE or GitLab Server CE.  If your GitLab Server version is 10.2 and newer, a personal access token must be configured.

  1. On the Jira Server dashboard menu, go to Git > Manage Git Repositories.
  2. The git configuration page for connecting repositories is displayed.
  3. On the Auto-connect integration panel, click GitLab.
  4. git for jira cloud auto-connect panel - select gitlab
  5. On the Connect to GitLab screen, select the External service from the dropdown list.
  6. Choose:
    • GitLab Server (CE/EE) Legacy  –  if your GitLab Server version is 10.1 and older.
    • Connect to GitLab Server using Legacy authentication Enter the Host URL of the GitLab server.  Enter the username and password credentials for server authentication.  If 2FA is enabled in your GitLab Server, enter the personal access token as the password.
    • GitLab Server (CE/EE)  –  if your GitLab Server version is 10.2 and newer.
    • Connect to GitLab Server using 2FA authentication Enter the Host URL of the GitLab server.  Enter the username and PAT credentials for server authentication.  2FA must be enabled in your GitLab Server and PAT has been configured.
  7. The Advanced option is only available for GitLab Servers.  Click Advanced to expand the option to enter the query string parameters.  This setting is used with integration to retrieve list of tracked repositories.  Set a filter that will only load some cloned repositories which can be viewed via Actions > Show tracked repositories in the Manage git repositories configuration screen.
  8. Click Connect. THe Git add-on will import detected GitLab Enterprise repositories.
  9. note
    Currently, the Git add-on scans only the repositories visible to the user which is used for scanning.  The repositories which are publicly visible (shared for all members or visible to the member with the admin rights) will not be scanned.  This will be supported in a future release.
  10. After the import process, the Settings dialog is displayed:
  11. jira server connect vsts settings dialog
  12. Click Finish.

The GitLab server is added to the repositories list as a connected server and is automatically reindexed.

Manage repositories of a connected GitLab server via the Git Repositories page under cog Actions  > Show tracked repositories to modify tracked repositories settings.

Repositories added or removed from GitLab server will be likewise added or removed from Jira Server.

fyi
The Git Integration for Jira add-on supports v3 and v4 of the GitLab API (in both Jira Cloud and Jira Server).
helpful tip
For newer GitLab authentication - in order to access a Git repository over HTTP, use the username as the username and the PAT for the password.
Admin/Power Users:
To pass the private access token (for example: XpigzF1JxMnAZ7mn9qgN) to an API call with GitLab.com:
curl --header "Private-Token: XpigzF1JxMnAZ7mn9qgN" https://gitlab.com/api/v4/projects?membership=true

Working with Branches and Merge Requests with GitLab CE/EE Jira Server

For GitLab CE/EE (Legacy or newer), the user must have the Write permissions and the api PAT scope.

  1. On your Jira Server, open a Jira issue.  On the Jira developer panel under Git Source Code, click Create Branch.
  2. The following dialog is displayed:
  3. Jira server issue page create branch dialog
    • Select a Repository from the list.
    • Choose a Base branch.
    • Enter a Branch name or leave it as is (recommended).
    If the Require User PAT option icons  is enabled in the Integration Settings and a user PAT isn't configured yet for the selected repository via Repository Browser, the following dialog is displayed instead: jira server issue create branch dlg PAT required
    • Click the link label to setup the PAT.  This will show the Repository Browser listing connected git repositories.
    • jira server repository browser enter user PAT
    • Click the  icons  icon to setup a PAT for the selected repository.  Paste a valid PAT of the current user to proceed.  Invalid PATs will fail the branch creation process.
    • Click  icons  to use this PAT and save it to the current user profile. Click  icons   to cancel setting up PAT for this repository.
    • After the above steps have been taken, the users will be able to proceed with branch creation.
  4. Click Create Branch.  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.

Merge Request

The merge request feature works the same as pull request.

To create a merge request and merge it to the main source (master):

  1. On your Jira Server, open the Jira issue where your previously created a branch.
  2. On the developer panel under Git Source Code, click Create merge request.
  3. The following dialog is displayed:
  4. Jira issue page create pull request dialog
    • Select Repository from the list.
    • Choose the newly-created branch as the Source branch.
    • Set master as the Target branch.
    • Enter a descriptive title or leave it as is (recommended).

    If the Require User PAT option icons is enabled and a user PAT isn't configured yet for the selected repository via Repository Browser, the dialog below is displayed instead:

    jira server issue page create pat dialog requiring to setup pat
    If an invalid PAT was configured for the selected repository, the merge request creation process will fail.
  5. Click Create to create the merge request.

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 CE/EE web portal.