# 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

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.threatrix.io/integrations/build-integrations/gitlab.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
