Skip to main content

Gitlab Compliance

Gitlab Compliance is a BDD compliance testing and documentation generation toolkit for GitLab CI/CD pipelines and project settings. It runs Gherkin policies against `.gitlab-ci.yml` and optional GitLab API settings. You can also generate markdown documentation for your Gitlab pipelines.

Source code - coming soon: MaturityBuilder/gitlab-compliance.

Get started

Get started{ .md-button .md-button-primary } Usage{ .md-button } BDD grammar{ .md-button }

gitlab-compliance supports two core workflows from the same pipeline YAML:

Workflow Command What it does
Compliance check Run Gherkin policies against .gitlab-ci.yml (and optional GitLab API settings)
Documentation generate Build Markdown, swagger-markdown, or HTML reference docs from .gitlab-ci.yml

gitlab-compliance check console demo

pip install gitlab-compliance

# Validate pipeline configuration against policies
gitlab-compliance check -f policies/ -p .gitlab-ci.yml

# Generate pipeline documentation (filter and group output as needed)
gitlab-compliance generate -i .gitlab-ci.yml --format swagger-markdown -o pipeline-reference.md
gitlab-compliance generate -i .gitlab-ci.yml --exclude variables,image --group-by stage

See Usage for the full CLI (including demos) and Generate pipeline documentation for output formats, --exclude, and --group-by.

  • compliance: Ensure pipeline YAML and project settings follow your security standards and custom policies
  • behaviour driven development: Policies are readable Gherkin scenarios that developers and security teams share
  • portable: Install from pip. See Installation
  • pre-merge: Validate configuration before changes land on protected branches
  • YAML and API: Offline checks against pipeline files; optional GitLab API checks for project settings and CI variables
  • easy to integrate: Run in GitLab CI or local git hooks
  • segregation of duty: Keep policy packs in a separate repository or OCI registry
  • documentation: Generate Markdown or HTML reference docs from .gitlab-ci.yml

Idea

gitlab-compliance focuses on negative testing — catching misconfigurations and policy violations — rather than proving that a job runs successfully end to end.

GitLab CI pipelines are defined in YAML that composes jobs, includes, variables, and workflow rules. What was missing is a lightweight way to assert that this configuration follows organizational standards before merge. GitLab offers native compliance features in higher tiers; gitlab-compliance provides an open, portable alternative inspired by terraform-compliance and Conftest.

For example, a policy might require that no job uses a floating latest image tag:

if a job defines an image, it must not use the :latest tag

translates into:

Given I have any job defined
When it has image
Then its image must not match ":latest$"

The image value comes from your pipeline YAML:

scan:
  image: python:3.12
build:
  image: docker:latest   # violates the policy above

In CI, this scenario runs against .gitlab-ci.yml (and resolved local includes) so merge requests cannot introduce violations.

See Examples for more sample use cases.

Supporting / Requirements

  • Python: 3.12 (see Installing via pip)
  • Pipeline file: .gitlab-ci.yml or another path passed with -p
  • API checks (optional): GitLab token plus --project or --group for settings and CI variable policies

Full CLI options: Usage. Step grammar: BDD Reference.

How can you support the project?

Contributions are welcome — see Contributing.

Metadata

Release files for gitlab-compliance 2.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gitlab-compliance 2.7.0
File Size Uploaded Provenance Actions
gitlab_compliance-2.7.0.tar.gz 130.5 kB With provenance Details for gitlab_compliance-2.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gitlab-compliance 2.7.0
File Interpreter ABI Platform Actions
gitlab_compliance-2.7.0-py3-none-any.whl Python 3 none any Details for gitlab_compliance-2.7.0-py3-none-any.whl

Total release size: 294.6 kB

Release files / gitlab_compliance-2.7.0.tar.gz

Download URL gitlab_compliance-2.7.0.tar.gz
Size 130.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3f08e50087d3a1aea9d05dbd729b3b48d6578f7b1f26410f5959563f52e21ae7
BLAKE2b-256 checksum
How to use checksums
2d1140bb58cce7d18a96abe5ce8ccf6676ab80ac6d7591754cc5d4c0f28b6eaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / gitlab_compliance-2.7.0-py3-none-any.whl

Download URL gitlab_compliance-2.7.0-py3-none-any.whl
Size 164.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de966e13b7ac54106de3a4f6e865ea03a5797108bd7d05c92f4e5f3535fa0e50
BLAKE2b-256 checksum
How to use checksums
e4bd8be6df9869885e87ef248d215d118a2a6ccc223ea7a79f53e0927627853e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for gitlab-compliance 2.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gitlab_compliance-2.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page