# CI integration

Canonical: https://snapvisor.io/docs/ci-integration

> Connect Snapvisor to GitHub or GitLab, authenticate uploads with project tokens or tokenless auth, and split large suites across machines with parallel testing.



Snapvisor is designed to run inside the CI you already have: your pipeline uploads screenshots, Snapvisor diffs them and posts a status check back to the pull request on GitHub or GitLab. For ready-to-copy GitHub Actions workflows, including merge queues and fork pull requests, see [GitHub Actions recipes](/github-actions).

## Access tokens [#access-tokens]

Snapvisor has two kinds of credentials — using the right one keeps CI uploads and agent access cleanly separated:

* **Project token** (the `ARGOS_TOKEN` you set in CI) authenticates screenshot uploads for a single project. It is upload-scoped: it can send builds, but it cannot read the API or drive the MCP server. Find it under your project's settings; store it as a CI secret and rotate it from the same screen if it leaks.
* **Personal access token** acts on your behalf across the REST API and the MCP server. Create one under Settings → Tokens. Use it for scripts, agents, or any headless MCP connection.

<Callout type="warn">
  Personal access tokens carry your account's access — treat them like a password and revoke unused ones.
</Callout>

## GitHub tokenless authentication [#github-tokenless-authentication]

On GitHub Actions your builds can authenticate without setting an `ARGOS_TOKEN` at all. When a build runs inside a GitHub Actions workflow on a connected repository, Snapvisor trusts the workflow's context to authorize the upload — no long-lived secret to store or rotate.

Requirements:

* The project must be connected to its GitHub repository.
* The build has to run in that repository's GitHub Actions — not a fork or an unrelated CI provider.

Running against a Vercel preview from a `deployment_status` workflow? Use a project token there instead; see [Run on a preview deployment](/run-on-preview-deployment).

Tokenless authentication is a per-project switch; disable it if you want every CI run to set an explicit token. For a middle ground that still avoids a static secret, Snapvisor also supports short-lived GitHub OIDC tokens.

## Parallel testing [#parallel-testing]

Large suites run faster when sharded across machines. Snapvisor groups the shards into one build so review stays a single, coherent step.

Each parallel shard uploads its screenshots as a **batch** tagged with a shared `nonce`, so Snapvisor knows they belong to the same build. The build tracks how many batches it expects against how many it has received; once every batch lands, the build finalizes and the comparison runs across all shards at once.

Two modes decide when a parallel build is complete:

* **Automatic** — you declare the total shard count up front. The build finalizes on its own once that many batches arrive, and aborts after a timeout if the last batch never does.
* **Manual** — the shard count isn't known ahead of time, so the build stays open until you run an explicit finalize command:

```bash
# after every shard has uploaded its batch, close the build
npx @snapvisor/cli finalize
```

<Callout type="warn">
  In manual mode a build that never receives its finalize command will expire while waiting — wire the finalize step so it always runs after your shards complete.
</Callout>

Parallel builds behave like any other build once finalized — they diff against the same baseline and post a single check to your pull request. Combine them with summary checks to require the whole run before merge.

## Upload options [#upload-options]

`buildName` and `subset` apply to `npx @snapvisor/cli upload` and to the SDKs built on `@snapvisor/core`, and each can also be set through an environment variable. `ignoreUploadFailures` is a reporter option only.

| Option                 | CLI flag                | Environment variable | What it does                                                                           |
| ---------------------- | ----------------------- | -------------------- | -------------------------------------------------------------------------------------- |
| `buildName`            | `--build-name <string>` | `ARGOS_BUILD_NAME`   | Names the build, so one CI job can create several builds on the same commit.           |
| `subset`               | `--subset`              | `ARGOS_SUBSET`       | Marks a build that holds only part of your screenshots.                                |
| `ignoreUploadFailures` | none                    | none                 | Playwright and Vitest reporter option. Keeps the test run green when the upload fails. |

### Build name [#build-name]

Give each build in a job its own name when one commit produces more than one build, for example an end-to-end run and a Storybook run:

```bash
npx @snapvisor/cli upload ./e2e-screenshots --build-name e2e
npx @snapvisor/cli upload ./storybook-screenshots --build-name storybook
```

Snapvisor tracks each name as a separate build, and the name is added to the status check (`snapvisor/<build>`, or `snapvisor/<project>/<build>` when several projects share the repository). A build named `default`, which is the name when you set none, gets no suffix. See [GitHub status checks](/github#check-names-and-states).

In the Playwright reporter `buildName` can also be an object that picks the name per test. It lists every possible name in `values`, so sharded runs upload each one, and a `get` function that receives the test case and returns one of them:

```ts
buildName: {
  values: ["desktop", "mobile"],
  get: (test) => (test.parent.project()?.name === "mobile" ? "mobile" : "desktop"),
},
```

### Subset builds [#subset-builds]

Use `--subset` (or `subset: true` in the SDK) when a run skips tests, for example when CI only runs the tests affected by a change:

```bash
npx @snapvisor/cli upload ./screenshots --subset
```

Without the flag, a screenshot that exists in the baseline but not in the upload is reported as removed. On a subset build Snapvisor does not treat that as a change:

* Missing screenshots are not counted as removed, and they do not add to the "changes awaiting review" count.
* The build is not eligible to become a baseline for later builds, because it is incomplete.

Only use `--subset` on runs that are really partial. A full run marked as subset hides genuinely deleted screenshots.

### Ignore upload failures [#ignore-upload-failures]

By default a failed upload fails the run. The Playwright and Vitest reporters accept `ignoreUploadFailures` to log the error and keep the exit code unchanged, so a Snapvisor outage or an expired token does not block unrelated work:

```ts
// playwright.config.ts
createArgosReporterOptions({
  uploadToArgos: !!process.env.CI,
  ignoreUploadFailures: true,
});
```

The error is still printed, followed by a warning that the failure was ignored. What the pull request shows depends on where the upload failed:

* **The build could not be created** (bad token, outage): no build exists, so the pull request gets no Snapvisor status check. If that check is required, the merge waits for a check that never arrives.
* **The build was created but the screenshots did not arrive** (upload or finalize step failed): the pull request shows a pending "Build is queued" check. After about an hour Snapvisor expires the build and the check fails with "Build expired — screenshots never arrived".

The CLI has no such option: `upload` exits non-zero when the upload fails.

## Notifications [#notifications]

Snapvisor can send Slack and email notifications when a visual regression lands on a branch you watch.

