GitLab Workflow

Prerequisites

Scanning requires a XEIZE token. To post merge request (MR) comments in automatic mode without an explicit scan scope, you also need a GitLab API token.

XEIZE Token

Add XEIZE_TOKEN as a CI/CD variable. To obtain one, contact your representative or support@xeize.dev.

GitLab PAT Token

Set XEIZE_GITLAB_API_TOKEN to a personal access token with the api scope. XEIZE uses GITLAB_API_TOKEN only when XEIZE_GITLAB_API_TOKEN is empty.

The token owner must be a project member with permission to read the code and comment on MRs. read_api is read-only, and write_repository grants Git push access. Neither grants the REST API permission to post comments. See GitLab’s token scopes and project permissions.

For token creation, see the GitLab PAT guide. To block merging when the job fails, require a successful pipeline in the project’s merge settings.

Scan result language

Add LANG to variables to choose the language of SAST, Secret, and IaC findings and comments on the merge request.

yaml
variables:
  LANG: "JP"

Supported values are KO (Korean), EN (English), and JP (Japanese). Korean is the default when LANG is unset.

Examples

SAST

yaml
image: alpine:3.24
stages:
  - sast
before_script:
  - apk update && apk add --no-cache git curl
variables:
  GIT_STRATEGY: clone
  GIT_DEPTH: 0
  LANG: "JP"
sast:
  stage: sast
  script: |
    curl -L -o xez_ci "https://download.xeize.dev/ci/ci_linux_x64" -H "X-XEZ-TOKEN: $XEIZE_TOKEN"
    chmod +x xez_ci
    GIT_PLATFORM=gitlab ./xez_ci

Secret

yaml
image: alpine:3.24
stages:
  - secret
before_script:
  - apk update && apk add --no-cache git curl
variables:
  GIT_STRATEGY: clone
  GIT_DEPTH: 0
  MODE: secret
  LANG: "JP"
secret:
  stage: secret
  script: |
    curl -L -o xez_ci "https://download.xeize.dev/ci/ci_linux_x64" -H "X-XEZ-TOKEN: $XEIZE_TOKEN"
    chmod +x xez_ci
    GIT_PLATFORM=gitlab ./xez_ci

IaC

yaml
image: alpine:3.24
stages:
  - iac
before_script:
  - apk update && apk add --no-cache git curl
variables:
  GIT_STRATEGY: clone
  GIT_DEPTH: 0
  MODE: iac
  LANG: "JP"
iac:
  stage: iac
  script: |
    curl -L -o xez_ci "https://download.xeize.dev/ci/ci_linux_x64" -H "X-XEZ-TOKEN: $XEIZE_TOKEN"
    chmod +x xez_ci
    GIT_PLATFORM=gitlab ./xez_ci

Blocking merges with LEVEL

yaml
image: alpine:3.24
stages:
  - sast
before_script:
  - apk update && apk add --no-cache git curl
variables:
  GIT_STRATEGY: clone
  GIT_DEPTH: 0
sast:
  stage: sast
  script: |
    curl -L -o xez_ci "https://download.xeize.dev/ci/ci_linux_x64" -H "X-XEZ-TOKEN: $XEIZE_TOKEN"
    chmod +x xez_ci
    GIT_PLATFORM=gitlab LEVEL=high ./xez_ci

Filtering findings with AUDIT LEVEL

yaml
image: alpine:3.24
stages:
  - iac
before_script:
  - apk update && apk add --no-cache git curl
variables:
  GIT_STRATEGY: clone
  GIT_DEPTH: 0
iac:
  stage: iac
  script: |
    curl -L -o xez_ci "https://download.xeize.dev/ci/ci_linux_x64" -H "X-XEZ-TOKEN: $XEIZE_TOKEN"
    chmod +x xez_ci
    GIT_PLATFORM=gitlab MODE=iac LEVEL=high AUDIT_LEVEL=low ./xez_ci

Push pipeline without an MR

This runs SAST, Secret, and IaC with MODE=all when code is pushed to develop, then builds and deploys after a successful scan. Add XEIZE_TOKEN as a CI/CD variable.

yaml
workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'

stages: [security, build, deploy]

security:
  stage: security
  image: alpine:3.24
  allow_failure: false
  variables:
    GIT_DEPTH: "0"
    MODE: all
    LEVEL: medium
  before_script:
    - apk add --no-cache git curl
  script: |
    curl -fsSL -H "X-XEZ-TOKEN: $XEIZE_TOKEN" https://download.xeize.dev/ci/ci_linux_x64 -o /tmp/xez_ci
    chmod +x /tmp/xez_ci
    GIT_PLATFORM=gitlab /tmp/xez_ci

build:
  stage: build
  needs: [security]
  script:
    - ./ci/build.sh

deploy:
  stage: deploy
  needs: [build]
  script:
    - ./ci/deploy.sh

Replace build/deployment commands and runner settings for your project while preserving the security → build → deploy dependencies. See common settings for scan scope and error handling.

Full scans and comparison bases

If your deployment process puts the same commit on main and develop, add SCAN_SCOPE: full to security.variables in the example above. Keep MODE: all and LEVEL: medium to decide whether to block deployment using full-scan results, including unchanged code.

To apply full scans to separate SAST, Secret, and IaC jobs, add the following setting to the pipeline-level variables.

yaml
variables:
  SCAN_SCOPE: full

Keep LEVEL=medium and set allow_failure: false on each security job. If you already use needs, configure the build to wait for all security jobs to succeed.

To scan only changes, remove the full-scan setting and use either BASE_BRANCH: release or BASE_COMMIT: "<full approved commit SHA>", replacing the placeholder with the full approved commit SHA. Branch mode compares changes since the common ancestor; commit mode compares directly with the specified file state. With an explicit scope, results appear in CI logs for manual, scheduled, and PR/MR runs too, without a comment token.

See scan scope settings for Secret's current-commit coverage, option precedence, and the operational-error policy.

Related pages1