• Get started
  • Documentation

Use deployment gating with GitLab

The deployment gating feature allows you to bring change requests from GitLab to Jira Service Management for approval. Once set up, any GitLab deployments to your selected environments are automatically sent to approvers in Jira Service Management and will only deploy if approved.

Before you can use deployment gating with GitLab, you must first:

You should also be on either GitLab Premium or Ultimate plans to complete the settings required for enabling deployment gating.

At this point, your service project is ready to connect to GitLab repositories.

Enable deployment gating in GitLab

When enabling GitLab during deployment tracking, you’ve provided a Service ID and connected your services to GitLab. To enable deployment gating:

When enabling GitLab during deployment tracking, you’ve provided a Service ID and connected your services to GitLab. To enable deployment gating:

  1. Log in to your GitLab. On the left sidebar, select Search or go to and find your project.

  2. Select Settings > Integrations.

  3. Select GitLab for Jira Cloud app.

  4. You’ll see the Service ID field which you’ve filled previously for deployment tracking. Now you’ll see additional options under Deployment Gating.

  5. Select Enable deployment gating.

  6. In the Environment Tiers field, enter the name of the environment you wish to enable deployment gating for. You can enter productionstagingtesting, and development as environment names. Use a comma between each environment name to add multiple. Please use lowercase letters only and avoid typos. 

  7. Select Save changes.

  8. Go back to you service project and navigate to Project settings > Change management.

  9. In the Deployment pipelines tab, under Deployment gating select Allow or prevent deployments using statuses in the change request workflowRead more about setting up deployment gating.

  10. Now, your project is ready for the deployment gating. To complete the setting you’ll need to enter your personal access token in the Service account token field.

Create the service account token

To create a service token in GitLab, you must first create a personal access token. This will authenticate the service account token, which we’ll then use to manage GitLab deployment through approvals and rejections given to changes in Jira Service Management. 

  1. To create a personal access token, you must first create a service account user in GitLab. Read how to create a service account in GitLab.

  2. Add the service account you created to a project using the personal access token. Read how to add service account as a member to a group or project.

  3. Then, add the service account to protected environments in GitLab. Read how to add service account to protected environments.

  4. Finally, generate a Service account token in GitLab using your personal access token. Read how to create acces token for service account.

  5. Go back to you service project in Jira Service Management. Navigate to Project settings > Change managementagain.

  6. Paste your generated token into the Service Accounts Token field. 

  7. Select Save to activate deployment gating in GitLab.

Add your Service account

  1. Go back to your GitLab and select your project under groups.

  2. Select Settings > CI/CD.

  3. Expand Protected environments and select Protect an environment.

  4. Add a new protected environment, like, staging.

  5. From Allowed to deploy select who is allowed to deploy to this environment. For example, Developers+Maintainers.

  6. Select the service account you created earlier as an approver in the Approvers field.

  7. Select Protect to save the changes.

Sample requests

You can use the examples below to send requests to the following APIs.

Create service account

1 curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --data "name=<name_of_your_choice>&username=<username_of_your_choice>" "<https://gitlab.com/api/v4/groups/<group_id>/service_accounts"

 

Create project using the personal access token

1 2 3 4 curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ --data "user_id=<service_account_id>&access_level=30" "https://gitlab.com/api/v4/groups/<group_id>/members" curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ --data "user_id=<service_account_id>&access_level=30" "https://gitlab.com/api/v4/projects/<project_id>/members"

 

Create access token using personal access token

1 curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.com/api/v4/groups/<group_id>/service_accounts/<service_account_id>/personal_access_tokens" --data "scopes[]=api,read_user,read_repository" --data "name=service_accounts_token"




Still need help?

The Atlassian Community is here for you.