# EkLine GitLab Integration

## Prerequisites

* **EkLine Integration Token:** Retrieve this from **Settings > Organization > Access** in the **[EkLine Dashboard](https://ekline.io/dashboard)**.
* **GitLab Project:** Admin access to configure CI/CD variables.

## Quick start

To enable EkLine, create, or update the `.gitlab-ci.yml` file in your project root with the following configuration.

```yaml
stages:
  - ekline-pr-review

ekline-pr-review-job:
  stage: ekline-pr-review
  image: ghcr.io/ekline-io/ekline-ci-cd:v6
  interruptible: true
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  script:
    - echo "Running EkLine"
  variables:
    INPUT_EK_TOKEN: $EK_TOKEN
    INPUT_GITLAB_TOKEN: $GITLAB_API_TOKEN
    INPUT_CONTENT_DIR: '<path_to_content_directory>'
    INPUT_REPORTER: 'gitlab-mr-discussion'
    INPUT_FILTER_MODE: 'added'
    # INPUT_IGNORE_RULE: "EK00001,EK00004" # Optional
    # INPUT_EXCLUDE_DIRECTORIES: "docs/archive" # Optional: one per line for multiple
    # INPUT_EXCLUDE_FILES: "README.md" # Optional: one per line for multiple
```

Replace **`<path_to_content_directory>`** with the actual path to your content directory.

## Use an interruptible pipeline

The configuration above includes `interruptible: true` on the review job. This setting automatically cancels a running EkLine review when you push a new commit to the same merge request. Without it, multiple review jobs can run in parallel on the same merge request, which wastes CI/CD minutes and can produce duplicate or outdated review comments.

> **Tip**: Combine `interruptible: true` with the GitLab project setting **Auto-cancel redundant pipelines** (under **Settings > CI/CD > General pipelines**) to ensure only the latest pipeline runs for each merge request.

## Configure GitLab API token

1. In GitLab, go to Settings > Access tokens.
2. Create a token with API access.
3. Add the token to your project's CI/CD > Variables as **`GITLAB_API_TOKEN`**.

## Configure EkLine integration token

1. Obtain your integration token by navigating to **Settings > Organization > Access** in the [EkLine dashboard](https://ekline.io/dashboard).
2. Add the token to your project's CI/CD > Variables as **`EK_TOKEN`**.

## Configure input reporter (optional)

You can choose between two options for **`INPUT_REPORTER`**:

- **`gitlab-mr-discussion`** (default): Reports results as merge request discussions.
- **`gitlab-mr-commit`**: Reports results to each commit in GitLab MergeRequest.

## Configure input filter mode (optional)

The following options are available for **`INPUT_FILTER_MODE`**:

- **added** default: Filter results by added or modified lines.
- **`diff_context`**: Filter results by diff context. That's changed lines +-N lines, such as N=3.
- **`file`**: Filter results by added or modified file. EkLine reports results if they're in added or modified files even if the results aren't in the actual diff.
- **`nofilter`**: Don't filter any results. Useful for posting results as comments as much as possible and checking other results in the console at the same time.

## Ignoring specific optional rules

To ignore specific rules during the review process, you can use the `INPUT_IGNORE_RULE` flag. This flag accepts a comma-separated list of rule identifiers that you wish to skip.

For example, to ignore rules `EK00001` and `EK00004`, you can set the `INPUT_IGNORE_RULE` flag in your configuration like this:

```
  INPUT_IGNORE_RULE: "EK00001,EK00004"
```

## Exclude specific content directories and files

- **Exclude specific directories** from review.
- **Exclude specific files** from review.

## Example usages

**Exclude directories and files:**
```yaml
variables:
  INPUT_CONTENT_DIR: 'docs'
  INPUT_EXCLUDE_DIRECTORIES: |-
    docs/archive
    docs/drafts
  INPUT_EXCLUDE_FILES: |-
    README.md
    docs/legacy.md
```

**Exclude files only:**
```yaml
variables:
  INPUT_EXCLUDE_FILES: |-
    README.md
    CONTRIBUTING.md
```


Once you have configured the options, save your changes and push the **`.gitlab-ci.yml`** file to your repository. Now, EkLine runs on your content directory and gives feedback as merge request discussions tailored to your custom settings.

## Next steps

- [Ignoring rules](/reviewer/configuration/ignoring-rules/) — handle false positives and suppress specific checks
- [Framework support](/reviewer/configuration/framework-support/) — configure EkLine for MDX, Astro, Docusaurus, and other frameworks
- [Docs Agent](/agent/) — generate and update documentation from your codebase with AI