# GitLab CI

> Send VisualCI builds from GitLab CI. The CLI reads the commit, branch and merge request from GitLab's variables.

Source: https://visualci.com/docs/ci/gitlab/
All of VisualCI's documentation: https://visualci.com/llms.txt

The CLI reads the commit from `CI_COMMIT_SHA`, the branch from `CI_COMMIT_REF_NAME` and the merge request from `CI_MERGE_REQUEST_IID`. In a merged results pipeline it reports the source branch's commit and name (`CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` and `CI_MERGE_REQUEST_SOURCE_BRANCH_NAME`), not the merge commit.

```yaml
visual:
  image: node:lts
  variables:
    GIT_DEPTH: 0 # VisualCI finds the baseline through the commit's ancestors
  script:
    - curl -fsSLo visualci.tar.gz https://github.com/DocSpring/visualci/releases/download/v0.2.34/visualci-x86_64-unknown-linux-musl.tar.gz
    - echo "0528c8a6805c3b928eca239fcf6df5cdd09ea03ff1dcd659c66ca888dc40e948  visualci.tar.gz" | sha256sum -c
    - mkdir -p /usr/local/bin && tar xzf visualci.tar.gz --strip-components=1 -C /usr/local/bin visualci-x86_64-unknown-linux-musl/visualci
    - export VISUALCI_BUILD_ID=$(visualci build create)
    - npm test -- -u
    - visualci upload --from auto src tests
    - visualci build finalize --wait
```

Add `VISUALCI_TOKEN` (a project token) as a masked CI/CD variable.

## Reviewing without a GitHub check

VisualCI posts its check to GitHub pull requests only. For a GitLab repository, choose how the pipeline learns the result with the project's CI mode (on its **Settings** tab, or `update_project` over MCP):

- `wait`: `visualci build finalize --wait` waits until the changes are approved or rejected, then passes or fails.
- `strict`: the job fails on any change that hasn't been approved.
- `review` (the default): the job passes, and the changes wait on VisualCI for your agent to review.

`finalize --wait` exits 0 when CI should pass, 1 when it should fail, and 3 when it timed out (after 900 seconds, or `--timeout`).
