GitLab Integration
This guide will walk you through setting up the EkLine integration with GitLab.
Prerequisites
- You have an EkLine API token provided by the EkLine contact person.
- You have a GitLab account and a GitLab API token.
Create .gitlab-ci.yml
file
Create a new file named .gitlab-ci.yml
in your project's root directory and add the following content:
stages:
- ekline-pr-review
ekline-pr-review-job:
stage: ekline-pr-review
image: ghcr.io/ekline-io/ekline-ci-cd:v6
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
Replace <path_to_content_directory>
with the actual path to your content directory.
Configure GitLab API Token
- In GitLab, go to Settings > Access tokens.
- Create a token with API access.
- Add the token to your project's CI/CD > Variables as
GITLAB_API_TOKEN
.
Configure EkLine API Token
- Obtain your
EK_TOKEN
from the EkLine contact person. - 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 (N=3 for example).file
: Filter results by added or modified file. EkLine will report results as long as they are 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 check other results in the console at the same time.
Ignoring Specific Rules (Optional)
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, if you want to ignore rules EK00001
and EK00004
, you can set the INPUT_IGNORE_RULE
flag in your configuration like this:
INPUT_IGNORE_RULE: "EK00001,EK00004"
Once you have configured the options, save your changes and push the .gitlab-ci.yml
file to your repository. Now, EkLine will run on your content directory and give feedback as merge request discussions.