GitLab
Last updated
Last updated
is a Git-based version control system with cloud and self-hosted options. By integrating GitLab with Cortex, you can import entities, view commits alongside other events, and monitor development maturity with Scorecards.
There are two options for integrating GitLab: the default configuration method and Cortex Axon Relay, a relay broker allows you to securely connect your on-premises GitLab data.
Before getting started:
A GitLab user with at least the Maintainer
role must create a GitLab or with the read_api
scope.
We recommend that you create the token at the parent group level, as GitLab does not support using a scoped token to read members from a parent group. If you do not create the token at the parent level, then you will need to manually configure groups in your GitLab settings in order for identity mapping and teams to work as expected.
If you're using the Scaffolder for entities in a given GitLab instance, make sure that configuration has the full api
scope.
If you're using a self-hosted instance of GitLab, you'll need to verify that your Cortex instance is able to reach the GitLab instance. We route our requests through a static IP address. Reach out to support at to receive details about our static IP. If you're unable to directly allowlist our static IP, you can route requests through a secondary proxy in your network that has this IP allowlisted and have that proxy route traffic to your GitLab instance.
In Cortex, navigate to the :
In Cortex, click your avatar in the lower left corner, then click Settings.
Under "Integrations", click GitLab.
Click Add configuration.
Configure the GitLab integration form:
Account alias: Enter the alias you will use to tie entity registrations to different configuration accounts.
Token: Enter your personal or group access token.
Host: Enter your host. If using a custom GitLab instance, enter the URL without the API path (e.g. https://gitlab.getcortexapp.com
)
Hide personal projects: Toggle this setting on if you do not want your personal projects pulled in to Cortex. Toggle this setting off to allow Cortex to pull your personal projects.
Click Save.
Once you save your configuration, you'll see it listed on the integration's settings page in Cortex. If you’ve set everything up correctly, you’ll see the option to Remove Integration in Settings.
You can also use the Test all configurations button to confirm that the configuration was successful. If your configuration is valid, you’ll see a banner that says “Configuration is valid. If you see issues, please see documentation or reach out to Cortex support.”
The GitLab integration has multi-account support. You can add a configuration for each additional by repeating the process above.
Each configuration requires an alias, which Cortex uses to correlate the designated with registrations for various entities. Registrations can also use a default configuration without a listed alias. You can edit aliases and default configurations from the GitLab page in your Cortex settings. Select the edit icon next to a given configuration and toggle Set as default on. If you only have one configuration, it will automatically be set as the default.
Cortex will discover entities for import from your GitLab configuration(s). These will appear in the import entities workflow.
Git
By specifying the x-cortex-git
field in your Cortex entity descriptor, you'll be able to see Git information in the entity page, including the top language, recent commits, and top contributors.
repository
GitLab project ID or namespace/repo
as defined in GitLab
✓
basepath
Subdirectory for the entity if it is in a monorepo
alias
Alias for the configuration in Cortex (only needed if you have opted into multi-account support)
Only one repository can be defined for in a given entity's YAML in the x-cortex-git
block.
Ownership
You can define the following block in your Cortex entity descriptor to add your GitLab groups.
Team name should match the group name in GitLab.
type
Ownership type; must be defined as group
for GitLab teams
✓
name
GitLab team name
✓
provider
Name of integration (in this case, GITLAB
)
✓
description
Description for the GitLab team
Cortex maps users' email addresses to discovered GitLab accounts, so you never need to define email ownership in an entity descriptor.
The GitLab integration will populate the Repo and Language detail blocks on an entity's details page.
In the Recent activity preview, you'll find the recent commits and releases. These will also appear in the event timeline.
These data will appear for entities imported from a Git source or those that have a Git repo defined in their YAMLs.
Events
On an entity's Events page, you can find all of the commits and releases associated with that entity. Each is hyperlinked to the commit or release page in GitLab and includes a timestamp.
Repository
You can access more detailed information pulled from GitLab in the Repository page in the entity's sidebar. At the top of the page, you'll find the repo associated with that entity and the most-used language in files for that entity. In the Top contributors block, you'll find the three users who have contributed the most code and the number of their contributions.
In the Commits section, you'll find the 10 most recent commits and metadata about each. Below Commits is the Recent releases section, which includes the 5 most recent releases.
Packages
When a GitLab team is registered in a team entity descriptor, Cortex will pull GitLab users in to the Members tab. When available, Cortex will pull in the profile picture and email address for each user.
Merge requests from GitLab are refreshed every 2 minutes.
Average MR open to close time
Avg time to first review
Avg time to approval
MRs opened
Weekly MRs merged
Avg MRs reviewed/week
Avg commits per MR
Avg lines of code changed per MR
You can read more about how Eng Intelligence tracks metrics for teams and users in the Eng Intelligence walkthrough.
With the GitLab integration, you can create Scorecard rules and write CQL queries based on GitLab data.
Ownership CQL
Cortex conducts a background sync of GitLab identities every day at 10 a.m. UTC. Merge requests are refreshed every 2 minutes.
Why is my CQL query git.branchProtection()
returning no results or a 403 error?
This can happen if you do not have the read_api
scope set for your access token, or if the GitLab user who generated the token does not have at minimum the Maintainer
role.
The following options are available to get assistance from the Cortex Customer Engineering team:
Chat: Available in the Resource Center
Slack: Users with a connected Slack channel will have a workflow added to their account. From here, you can either @CortexTechnicalSupport or add a :ticket:
reaction to a question in Slack, and the team will respond directly.
Don’t have a Slack channel? Talk with your Customer Success Manager.
Configure the integration for multiple GitLab accounts
Cortex supports mapping multiple identities for a single user if you have multiple configurations of GitLab. See the for more information.
Cortex supports a GitOps approach, which allows you to manage entities in Cortex through your version control system. If you would prefer this workflow over the UI for the GitLab integration, you must create a webhook. Please see the for instructions.
See the for instructions on importing entities manually.
You can confirm users' GitLab accounts are connected from .
If users are not loading in the identity mapping page, make sure that you have created your GitLab personal access token from the parent level as described in the .
Cortex uses the GitLab integration for a significant amount of data that appears on .
If team members are not appearing as expected, make sure that you have created your GitLab personal access token from the parent level as described in the .
The GitLab integration enables Cortex to pull information about merge requests into the Dev homepage. You can find your open merge requests under the and any merge requests assigned to you for review under the .
The also uses merge request data from GitLab to generate metrics:
To add deployments for your GitLab related entity, you can send a deployment event to the .
See more examples in the in Cortex.
Email: , or open a support ticket in the in app Resource Center
Packages are automatically scraped from your Git repos or they can be submitted via the . The package file must be in the root of your repository — or, if you're using basepath
, in the root of the subdirectory — to be scraped by Cortex. You can query an entity's packages in using packages()
.
To view packages, click Packages in the entity's sidebar.
The following package types are automatically scraped from repositories:
JavaScript / Node.js: package.json
, package-lock.json
, yarn.lock
, pnpm-lock.yaml
Python: requirements.txt
, pipfile.lock
.NET (C#): packages.lock.json
Java: pom.xml
Go: go.sum
All other files of these types can be added via the .