GitLab integration with Yandex Tracker
In Tracker issues, you can automatically add links to GitLab merge requests
You can also enable automatic creation of issue comments with information about merge requests. Auto comments are only available for Managed Service for GitLab.
To set up integration with GitLab in Tracker:
- Connect Yandex Tracker.
- Create a GitLab instance.
- (Optional) Create a GitLab project.
- Create a hook for integration.
- Test the hook.
- Check the result.
If you no longer need the resources you created, delete them.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Enable Yandex Tracker
Enable Tracker for your Yandex Cloud organization.
Create a GitLab instance
Create a Managed Service for GitLab instance or a VM with the GitLab image.
Create a Managed Service for GitLab instance by following this guide.
Launch GitLab on a VM with a public IP.
-
On the folder page in the management console
, click Create resource and selectVirtual machine instance
. -
Under Boot disk image, in the Product search field, enter
Gitlab
and select a public GitLab image. -
Under Location, select an availability zone to place your VM in. If you do not know which availability zone you need, leave the default one.
-
Under Computing resources, navigate to the
Custom
tab and specify the required platform, number of vCPUs, and the amount of RAM:- Platform:
Intel Ice Lake
. - vCPU:
4
. - Guaranteed vCPU performance:
100%
. - RAM:
8 GB
.
- Platform:
-
Under Network settings:
- In the Subnet field, select the network and subnet to connect your VM to. If the required network or subnet is not listed, create it.
- Under Public IP, keep
Auto
to assign your VM a random external IP address from the Yandex Cloud pool or select a static address from the list if you reserved one in advance.
-
Under Access, select SSH key and specify the VM access data:
- Under Login, enter the username. Do not use
root
or other names reserved by the OS. To perform operations requiring superuser permissions, use thesudo
command. -
In the SSH key field, select the SSH key saved in your organization user profile.
If there are no saved SSH keys in your profile, or you want to add a new key:
- Click Add key.
- Enter a name for the SSH key.
- Upload or paste the contents of the public key file. You need to create a key pair for the SSH connection to a VM yourself.
- Click Add.
The SSH key will be added to your organization user profile.
If users cannot add SSH keys to their profiles in the organization, the added public SSH key will only be saved to the user profile of the VM being created.
- Under Login, enter the username. Do not use
-
Under General information, specify the VM name:
ci-tutorial-gitlab
. -
Click Create VM.
It may take a few minutes to create the VM. When the VM status changes to RUNNING
and GitLab starts, configure its settings.
(Optional) Create a GitLab project
To set up integration for an individual GitLab project, create one.
-
Log in to the Managed Service for GitLab instance web interface.
-
Click Create a project.
-
Click Create blank project.
-
Fill in the fields as follows:
- Project name: Enter a name for the project.
- Project URL: Select the administrator user in the field next to the Managed Service for GitLab instance FQDN.
Leave the other fields unchanged.
-
Click Create project.
-
On the Yandex Compute Cloud page, select the created VM and copy its public IP.
-
Connect to the VM via SSH.
-
Get the GitLab administrator password using the following VM command:
sudo cat /etc/gitlab/initial_root_password
-
Copy the password (without spaces) from the
Password
row to the clipboard or a separate file. -
Open
http://<VM_public_IP_address>
in your browser. This will take you to the GitLab web interface. -
Log in using the administrator account:
- Username or email:
root
. - Password: Password you copied earlier.
If you are unable to log in, reset the administrator account password
. - Username or email:
-
Log in to the system again using the administrator account and the new password.
-
Select Create a project.
-
Give your project a name.
-
Click Create project.
Create a hook for integration
To link GitLab merge requests to Tracker issues, create a hook:
-
If you do not have an OAuth token for working with the Tracker API yet, get one.
-
Check if you have access to the API by requesting information about the current user.
-
Open a GitLab instance and go to the hook settings:
- To enable integration for the entire GitLab instance (GitLab admin privileges are required):
- In the left-hand panel, click the Your work drop-down list and select Admin Area.
- Go to System Hooks.
- To enable integration for an individual project:
- Go to the project you need.
- In the left-hand panel, click Settings and select Webhooks.
- To enable integration for the entire GitLab instance (GitLab admin privileges are required):
-
Specify the hook parameters:
-
URL:
https://api.tracker.yandex.net/v2/system/gitlab/receive?comments=true&<organization_type>=<organization_ID>
.Where:
-
comments=true
: Enables automatic creation of comments in an issue with a link to and information about merge requests. Disable it if commenting is not required. This parameter is only available for Managed Service for GitLab. -
<organization_type>
: It may take the following values:x_cloud_org_id
: If the type of your organization is Yandex Cloud Organization.x_org_id
: If the type of your organization is Yandex 360 for Business or both Yandex 360 for Business and Yandex Cloud Organization.
-
<organization_ID>
: ID of the organization from the Tracker organizations page .
-
-
Secret token: OAuth token of the bot that will be used to add the links, in
OAuth <token_contents>
format.
For example:OAuth y1_AQAD-qJScAAAEKEQbBNnChvfBIqR_yEQl_HMO0********
. -
In the Trigger section, disable all options except Merge request events.
-
In the SSL verification section, select Enable SSL verification.
-
-
Click Add system hook (Add webhook for an individual project).
The System Hooks (Project Hooks for an individual project) section with information about the created hook and its parameters will appear on the page.
Test the hook
- Under System Hooks (Project Hooks for an individual project), click Test.
- Select Merge request events from the drop-down list.
A test request should return a response saying Hook executed successfully: HTTP 204
. If the test request returns an error, the hook parameters are incorrect.
Check the result
-
Create an issue in Tracker.
-
Create a merge request
in GitLab and specify the issue key in its name or description. -
Make sure the Tracker issue now contains a link to the GitLab merge request under Links to external applications.
If you used Managed Service for GitLab and enabled auto comments when creating a hook, the issue will show a comment with the merge request link and details.
Delete the resources you created
Delete the resources you no longer need to avoid paying for them:
- Delete the Managed Service for GitLab instance or the created VM with the GitLab image.
- If you reserved a public static IP address for the VM, release and delete it.