# GitLab CI integration

Integrations / CI. Breadcrumb: [Home](https://osty.dev/) / [Integrations](https://osty.dev/integrations) / GitLab CI

In GitLab CI, `osty verify` runs as one job that fails on blocked or unvetted dependencies. Osty also classifies `.gitlab-ci.yml` with Ruby Psych semantics, resolving merge keys, `extends:`, `!reference` and `include:`, so a speculative pipeline that could deploy, publish or release is never triggered. Unresolvable composition always fails safe.

Table: How the classifier treats GitLab composition (ADR-0030)

| Construct | How Osty resolves it | Lowest possible class |
| --- | --- | --- |
| `<<` merge keys | Applied in document order with Psych semantics; earlier mappings win in a merge sequence. | Depends on the merged job. |
| `extends:` | Deep merge up to GitLab's 11-level limit; cycles and missing targets escalate. | `SIDE_EFFECT_POSSIBLE` on any error. |
| `!reference` | Resolved up to 10 nesting levels; referenced scripts are classified, never dropped. | `SIDE_EFFECT_POSSIBLE` if unresolved. |
| `include:` | Content is outside the file, so an `<include>` pseudo job is created. | `SIDE_EFFECT_POSSIBLE`; `SIDE_EFFECT_CONFIRMED` for deploy or release targets. |
| Deploy-like stages | Stage names containing `deploy`, `release`, `publish`, `production`, `rollout` or `promote` escalate unverified commands. | `SIDE_EFFECT_CONFIRMED`. |
| `environment:`, `release:`, `pages` | Starting or stopping an environment, releases and Pages jobs. | `SIDE_EFFECT_CONFIRMED`. |

The GitLab job's gate command:

```bash
osty verify --lockfile package-lock.json --json
```

## How do I add osty verify to .gitlab-ci.yml?

Run the job on a runner tagged `osty-edge` that mounts the edge verdict cache. The pipeline below also contains the composition patterns the classifier has to see through.

`.gitlab-ci.yml`:

```yaml
stages:
  - verify
  - test
  - release
  - deploy

include:
  - project: acme/ci-templates
    file: /templates/security.yml

.go-defaults: &go-defaults
  image: golang:1.26
  before_script:
    - go version

.release-script:
  script:
    - ./scripts/publish.sh

osty-verify:
  stage: verify
  image: golang:1.26
  tags: [osty-edge]
  variables:
    OSTY_EDGE_CACHE: /var/lib/osty/edge-cache.sqlite
    OSTY_POLICY_PATH: .osty/policy.yaml
  script:
    - CGO_ENABLED=0 go install github.com/osty-io/osty/cmd/osty@latest
    - osty policy validate .osty/policy.yaml
    - osty verify --lockfile package-lock.json --json

unit-tests:
  <<: *go-defaults
  stage: test
  script:
    - go test ./...

lint:
  extends: .go-defaults
  stage: test
  script:
    - go vet ./...

publish:
  stage: release
  script:
    - !reference [.release-script, script]

deploy-production:
  stage: deploy
  image: alpine/helm:3.16.2
  environment:
    name: production
  script:
    - helm upgrade --install api ./chart
```

## What does Osty report for this pipeline?

These are the classifier's real results for the file above. The pipeline as a whole is `SIDE_EFFECT_CONFIRMED`, so Osty never triggers it speculatively and verifies the change locally instead.

Table: Classifier output for the `.gitlab-ci.yml` on this page

| Job | Class | Reason reported |
| --- | --- | --- |
| `<include>` | `SIDE_EFFECT_POSSIBLE` | `include project:acme/ci-templates:/templates/security.yml` is not part of this file. |
| `osty-verify` | `SIDE_EFFECT_POSSIBLE` | The `go install` script line is an opaque command. |
| `unit-tests` | `SIDE_EFFECT_POSSIBLE` | The merged `before_script` line `go version` is opaque. |
| `lint` | `SIDE_EFFECT_POSSIBLE` | `go version` arrives through `extends: .go-defaults`. |
| `publish` | `SIDE_EFFECT_CONFIRMED` | `!reference` resolves to `./scripts/publish.sh` in the `release` stage. |
| `deploy-production` | `SIDE_EFFECT_CONFIRMED` | Deploys to environment `production` and runs `helm upgrade`. |

Rules, `only`, `except` and `when: manual` are not evaluated, so a deploy job that would be skipped on a speculative branch is still counted.

## Does osty stamp work in GitLab CI?

Not yet. `osty stamp` accepts `GITHUB_ACTIONS` and `CIRCLECI` as CI providers and rejects any other value, so GitLab pipelines cannot sign provenance today. Until then, Osty links GitLab workloads to commits through its pre-stamp lineage cascade, and reports workloads it cannot prove as missing provenance rather than guessing.

Current behavior when a GitLab provider is passed:

```text
osty stamp: invalid provenance statement: ci_provider "GITLAB_CI" must be one of GITHUB_ACTIONS, CIRCLECI
```

## How does osty-edge connect to GitLab?

The edge runtime config selects GitLab with `forge.provider: gitlab` and `ci.provider: GITLAB_CI`. One REST v4 client serves both, against gitlab.com or a self-managed instance. Mutating requests are never retried after a 5xx, because GitLab may already have applied the commit or merge.

## Frequently asked questions

### Does Osty support self-managed GitLab?

Yes. The base URL may be the instance root or end in `/api/v4`.

### Why is a pipeline built mostly from `include:` never `PURE_VERIFY`?

Included content is not in the classified file, so Osty cannot prove it side-effect free. Allowlist it in `ciGovernor.safeVerifyWorkflows` after review.

### What happens with duplicate YAML keys?

Osty keeps the last value as Psych does, and marks the job `SIDE_EFFECT_POSSIBLE` because the intended definition is ambiguous.

## Related pages

- [GitHub Actions integration](https://osty.dev/integrations/github-actions): The same gate plus `osty stamp` provenance.
- [Ship](https://osty.dev/ship): Fleet campaigns on Temporal, offline AI migrations capped at `VERIFIED_PR`, the Policy Patch Verifier, CI side-effect classification, canary gates and a stateful-safe kill switch.
- [Architecture](https://osty.dev/architecture): Plane 1 (`osty-brain`), the control plane (`osty-control`, PostgreSQL 17, Temporal) and the thin edge (`osty-edge`, `osty-proxy`, `osty-sensor`), plus the accepted ADRs behind them.
- [Osty vs Renovate](https://osty.dev/compare/osty-vs-renovate): Gate Renovate branches in CI with signed verdicts.

## See your fleet in 10 minutes

Connect a read-only GitHub App and cloud role. Osty installs nothing in your environment and writes nothing to your repositories, and the report shows false positives, stale deploys and unowned workloads.

Get a free X-Ray: https://osty.dev/xray

Written by Osty Engineering. Published 2026-11-29. Updated 2026-11-29.

Canonical: https://osty.dev/integrations/gitlab-ci
