# 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 -fsSL https://visualci.com/install.sh | VISUALCI_INSTALL_DIR=/usr/local/bin sh
    - 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`).
