> For the complete documentation index, see [llms.txt](https://docs.threatrix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.threatrix.io/integrations/build-integrations/gitlab.md).

# GitLab Pipeline

### Common Build Integration Documentation

This documentation is specific to Gitlab. [Common build server](/integrations/build-integrations.md) documentation should be reviewed before proceeding further.&#x20;

### Environment Variables

Environment variable values can be found in your [user profile](/threat-center-1/user-profile.md).

* THREATRIX\_OID - Your organization ID.
* THREATRIX\_EID - Your entityID (if you wish to override your default).
* THREATRIX\_API\_KEY - Personal or organization API key.

### Install Environment Variables

{% hint style="warning" %}
This step may require administrative privileges within Gitlab
{% endhint %}

From within Gitlab, navigate to Settings -> CI/CD -> Variables, as shown below.

![](/files/-MbtEsIU_FARUnsL8oY5)

Click "Add Variable" to add THREATRIX\_OID and THREATRIX\_API\_KEY and optionally, a THREATRIX\_EID for which the API key has permissions to create projects.

### Option 1: Add CLI Threat Agent

```
threatrix-scan:
  script:
    - curl -LJO https://github.com/threatrix/threat-agent-dist/releases/download/latest/threat-agent.jar
    - java -jar threat-agent.jar .
  only:
    - merge_requests
```

### Option 2: Add Docker Threat Agent Step to Build

In Gitlab, in the repository you wish you run your scan, create a `.gitlab-ci.yml file` and add the following contents.

{% hint style="warning" %}
This option may not work for Gitlab On-Prem deployments. Please use Option 1 for Gitlab On-Prem.
{% endhint %}

```
threatrix-scan:
  image: gitlab/dind
  script:
    - printenv > host.env
    - docker run -v $(pwd):/app --env-file=host.env threatrix/threat-agent ./
  only:
    - merge_requests

```
