# EkLine Docs Reviewer GitLab integration

## Prerequisites

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

## Quick start

Create or update the `.gitlab-ci.yml` file in your project root with this 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 cancels a running EkLine review when you push a new commit to the same merge request. Without it, several review jobs can run at once on the same merge request. That wastes CI/CD minutes and can post duplicate or outdated comments.

> **Tip**: Combine `interruptible: true` with the GitLab project setting **Auto-cancel redundant pipelines** (under **Settings > CI/CD > General pipelines**) so 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. Copy your integration token from **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 on each commit in the merge request.

## 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 in those files, even outside the 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 skip specific rules, set `INPUT_IGNORE_RULE` to a comma-separated list of rule IDs. For example, to skip `EK00001` and `EK00004`:

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

## Block merges until docs pass

By default, EkLine posts its findings as merge request discussions without failing the job, so the merge request can still merge. To make the review a required gate:

1. Add `INPUT_REVIEWDOG_FLAGS` to the job's `variables`, so the job fails when EkLine reports an issue at error severity:

   ```yaml
   variables:
     INPUT_REVIEWDOG_FLAGS: "-fail-level=error"
   ```

2. In your GitLab project, open **Settings** > **Merge requests**. Under **Merge checks**, select **Pipelines must succeed**, then save your changes.

## Exclude specific content directories and files

Set `INPUT_EXCLUDE_DIRECTORIES` and `INPUT_EXCLUDE_FILES` to skip directories and files. Put one path on each line.

## 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
```


Save your changes and push the **`.gitlab-ci.yml`** file to your repository. EkLine then reviews your content directory and posts its feedback as merge request discussions.

## 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