GitLab
Overview
Connect GitLab to StackGuardian to source Infrastructure as Code (IaC) and Policy code from your repositories and trigger Workflow runs automatically on pull requests, pushes, or tag creation.
To integrate GitLab with StackGuardian:
- Create a GitLab token. You have three options:
- Once the token is created, configure the connector in StackGuardian.
Create a personal access token
This method grants StackGuardian access to your GitLab account and all accessible projects. Follow these steps to create a personal access token:
- Log in to GitLab.
- Click on your avatar and select Edit profile.
- Go to Access Tokens in the sidebar.
- Click Add New Token.
- Provide a name for the token.
- Optionally, set an expiry date (default is 365 days).
- Select the api scope.
- Click Create Personal Access Token.
- Copy and store the token securely. It will not be shown again.

GitLab token creation
Create a group access token
This method limits StackGuardian's access to a specific GitLab group and its projects. Follow these steps to create a group access token:
- Log in to GitLab.
- Open the desired group.
- Go to Settings > Access Tokens.
- Click Add new token.
- Enter a token name.
- Set an expiry date (up to 365 days).
- Choose a role: Reporter or higher.
- Select scopes:
read_repository: Allows reading the repository.api: Permits API access that includes various read and write actions.
- Click Create group access token.
- Save the token securely. It won't be shown again.
Handle the Group Access Token with care, as it grants access to all projects within the group.
Create a project access token
This method limits StackGuardian’s access to a specific GitLab project. Follow these steps to create a project access token:
- Log in to GitLab.
- Open the desired project.
- Go to Settings > Access Tokens.
- Click Add new token.
- Enter a token name.
- Set an expiry date (up to 365 days).
- Choose a role: Reporter or higher.
- Select scopes:
read_repository: Allows reading the repository.api: Permits API access that includes various read and write actions.
- Click Create project access token.
- Save the token securely. It won't be shown again.
Handle the Project Access Token with care, as it grants repository access.

Project access token
Configure the connector in StackGuardian
Once you have the token, follow these steps:
- In StackGuardian, navigate to Organization Settings → Connectors → Version control providers.
- Select + Connect with VCS provider.
- In the Connect with VCP modal, select GitLab as the version control provider.
- Select your hosting type:
- GitLab.com — hosted on gitlab.com
- Self-managed — hosted on your own infrastructure
- Dedicated — hosted on a GitLab-managed dedicated instance
- Choose an authentication method:
GitLab.com
Use this hosting type if your repositories are hosted on gitlab.com.
No additional configuration is required — select your authentication method and proceed directly to the credentials section.
Personal access token
-
Enter a Connector name. The connector ID is auto-generated from the name.
-
Under Credentials, fill in the following:
Field Description User name Your GitLab username, for example john.doeAccess token A personal access token generated in GitLab -
Select Create to finalize the connector.

Connect with Personal access token
Group access token
- Enter a Connector name. The connector ID is auto-generated from the name.
- Under Credentials, enter the Access token generated for your GitLab group.
- Select Create to finalize the connector.

Group access token
Project access token
- Enter a Connector name. The connector ID is auto-generated from the name.
- Under Credentials, enter the Access token generated for your GitLab project.
- Select Create to finalize the connector.

Connect with Project access token
Self-managed
Use this hosting type if your GitLab instance is hosted on your own infrastructure.
In addition to selecting an authentication method, you must provide the URLs for your GitLab instance under Configuration:
| Field | Description |
|---|---|
| HTTP URL | Your GitLab instance URL, for example https://gitlab.yourcompany.com |
| API URL | Your GitLab API endpoint, for example https://gitlab.yourcompany.com/api/v4 |
Do not include a trailing slash in either URL.

Connect with Self-managed
Once you have filled in the Configuration fields, follow the same steps as the corresponding authentication method under GitLab.com above.
Dedicated
Use this hosting type if your GitLab instance is hosted on a GitLab-managed dedicated environment.
The HTTP URL and API URL fields are pre-filled with the default GitLab endpoints. Update these values if your dedicated instance uses custom URLs.
| Field | Default value |
|---|---|
| HTTP URL | https://gitlab.com |
| API URL | https://gitlab.com/api/v4 |
Do not include a trailing slash in either URL.

Connect with Dedicated selected
Once you have confirmed the Configuration fields, follow the same steps as the corresponding authentication method under GitLab.com above.