gitlab-ci-conventions
Skill7 starsChanged 3 days agoMITView on GitHub
GitLab CI mechanics, any instance or tier: rules, includes, scans, releases, Pages. TRIGGER when: editing `.gitlab-ci.yml`, `.gitlab/ci/`, `.gitlab/changelog_config.yml` or a CI/CD component `templates/*.yml`; setting up CI on GitLab; user asks about GitLab CI rules, runners, schedules, the vulnerability report, the coverage report, Releases or Pages. SKIP when: the repo is on GitHub (`github-actions-conventions`). Load `ci-conventions` alongside.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- leroyguillaume/skillsword for word, first seen Nov 22, 2026
Other versions1 project uses a version of this.
Word for word · 1
- leroyguillaume/skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository54 other files it gives its agents.
- adr-conventionsSkill
- api-conventionsSkill
- architecture-conventionsSkill
- argocd-conventionsSkill
- ci-conventionsSkill
- config-conventionsSkill
- contributing-conventionsSkill
- councilSkill
- cryptography-conventionsSkill
- dependency-update-conventionsSkill
- diagram-conventionsSkill
- docker-conventionsSkill
- documentation-conventionsSkill
- frontend-conventionsSkill
- github-actions-conventionsSkill
- github-issue-conventionsSkill
- github-pr-conventionsSkill
- github-repo-settingsSkill
- helm-conventionsSkill
- herdr-core-delegationSkill
- herdr-delegationSkill
- herdr-tui-delegationSkill
- kopf-conventionsSkill
- kubernetes-operator-conventionsSkill
- logging-conventionsSkill
- logo-conventionsSkill
- mise-conventionsSkill
- ollama-conventionsSkill
- openssf-conventionsSkill
- pr-conventionsSkill
- pre-commit-conventionsSkill
- project-metadata-conventionsSkill
- python-async-conventionsSkill
- python-conventionsSkill
- readme-conventionsSkill
- release-script-conventionsSkill
- release-supply-chain-conventionsSkill
- renovate-ci-conventionsSkill
- rest-conventionsSkill
- rust-build-conventionsSkill
- rust-conventionsSkill
- rust-http-conventionsSkill
- security-policy-conventionsSkill
- signal-handling-conventionsSkill
- sql-conventionsSkill
- starlight-conventionsSkill
- systemd-conventionsSkill
- system-user-conventionsSkill
- task-conventionsSkill
- terraform-conventionsSkill
- topic-splittingSkill
- ui-copy-conventionsSkill
- web-layout-conventionsSkill
- yaml-conventionsSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
rules:only: Never only:/except:. They can't be combined with rules: and they hide the real trigger logic. - Distinctive: line 176
Write the digest to an artifact file per arch.
- Very specific: line 290
Before GitLab 17.9, publish is not a pages: property: the job must be named pages and publish public through artifacts: paths:.
- Very specific: line 325
Never use only:/except:, and never filter a job with changes alone.
- Distinctive: line 327
Never include a template or component by branch, bare tag or remote URL.
- Distinctive: line 328
Never make publishing credentials unprotected, and never push from an MR pipeline.
- Distinctive: line 330
Never download a Trivy report template at run time.
- Very specific: line 331
Never create a GitLab Release for a tag with a -.
- Distinctive: line 332
Never let a Pages job run outside the default branch.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitLab CI conventions
How the pipelines from ci-conventions are written on GitLab. The skill
assumes nothing about the instance. Runner tags, registry host and tier all
vary, so read them from the repo or ask. Never guess a runner tag.
Layout and style
- One
.gitlab-ci.yml. Once it passes a couple of hundred lines, split it into.gitlab/ci/<pipeline>.yml(quality,coverage,build,security,chart,release,docs, each only whenci-conventionscalls for it), pulled in withinclude: local:. - Each canonical pipeline is a set of jobs, not a file. Name jobs in
lowercase kebab-case after what they do (
pre-commit,test,build-image,trivy-fs), and keep them static. Aparallel: matrixalready suffixes the name. rules:only. Neveronly:/except:. They can't be combined withrules:and they hide the real trigger logic.needs:to build a DAG. Stages are for ordering the UI, not for sequencing jobs.- Shared rules go through
!reference [.rules-build, rules]rather than YAML anchors, because anchors don't crossinclude:boundaries. pre-commit'scheck-yamlrejects custom tags, so give it the--unsafearg in a repo that uses!reference. - Block style, no leading
---, peryaml-conventions— with one exception:!referencetakes its path in flow style, the only form GitLab documents, so mark the line# yamllint disable-line rule:bracketsor the strict yamllint hook rejects it.
The pipeline header
workflow:
auto_cancel:
on_new_commit: interruptible
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
default:
interruptible: true- Without the second rule, a push to a branch with an open MR runs two pipelines, a branch one and an MR one.
interruptible: trueon every job, publishing included. That is the GitLab form of the "cancel superseded runs" rule. Never override it tofalse. Auto-cancel also needs the project setting Auto-cancel redundant pipelines, which is on by default. Leave it on.
rules:changes traps
changesis always true on tag pipelines, scheduled and manual pipelines, and the first push of a new branch. A job filtered only bychangestherefore runs on every schedule. Pairchangeswith anif:on the pipeline source:rules: - if: $CI_PIPELINE_SOURCE == "schedule" when: never - if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH changes: paths: - src/**/* - Cargo.toml - Cargo.lock - Dockerfile - .dockerignore - .gitlab/ci/build.yml- In an MR pipeline,
changescompares against the target branch. On a branch pipeline without an MR, addcompare_to: refs/heads/<default>. Otherwise it compares against the previous push only. - A job skipped by
rulesdoesn't block Pipelines must succeed. A pipeline with no job does. Becausequalityalways runs, that never happens.
Pinning include:
include:
- component: $CI_SERVER_FQDN/<group>/<project>/<name>@<40-char-sha> # 1.4.0
- project: <group>/<project>
ref: <40-char-sha> # v1.4.0
file: /templates/build.yml- A full SHA with the version as a comment, bumped by Renovate
(
dependency-update-conventions). Never a branch, never a bare tag. - No
include: remote:from a URL you don't control. Mirror the file into a project and include it by SHA. include: local:is the repo itself and needs no pin.
Publishing credentials
- Protect the release tag patterns (
v*,chart-*) so that only maintainers can create them. - Registry and API credentials for publishing are CI/CD variables that are protected and masked (hidden where the instance supports it). Protected variables only reach pipelines on protected branches and tags, so an MR pipeline never sees them. That is the whole point.
- Restrict
CI_JOB_TOKENaccess to the projects that actually need it (the job token allowlist).
coverage
One job, on the same rules as the test job:
coverage:
image: ghcr.io/jdx/mise:<mise version>-debian
allow_failure: true
script:
- mise install --locked
- mise exec -- task coverage
coverage: <the language skill's regex>
artifacts:
expose_as: coverage report
paths:
- <the language skill's HTML report directory>/
reports:
coverage_report:
coverage_format: cobertura
path: <the language skill's Cobertura file>allow_failure: trueis how it stays out of the merge gate: GitLab has no per-job required check, and Pipelines must succeed waits on every job not allowed to fail (ci-conventionssays why it does not gate).coverage:reads the total from the job log into the MR widget and the project's coverage history; the regex matches the line the tool prints.coverage_reportannotates the MR diff, line by line. It takes Cobertura, sotask coveragewrites that format too, at the path the language skill gives.
build
Define IMAGE once in top-level variables: ($CI_REGISTRY_IMAGE when
using the GitLab registry, otherwise the organisation's registry). Tags and
OCI labels derive from $CI_COMMIT_TAG, $CI_COMMIT_SHA and
$CI_PROJECT_URL, and are computed in one place.
One job with a
parallel: matrixoverARCHand a per-arch runner intags:. Ask the user which runner tags exist.parallel: matrix: - ARCH: - amd64 - arm64- In the same job:
docker buildx build --load --platform linux/$ARCH, then the two Trivy scans (below) on the loaded image, then, only when pushing, the same build again with--output type=image,push-by-digest=true,name-canonical=true,push=true. It is a cache hit, so the pushed layers are the ones that were scanned. Write the digest to an artifact file per arch. - A
manifestjob (needs:both arch jobs, pushing runs only) assembles the tags withdocker buildx imagetools create. - Layer cache:
--cache-from type=registry,ref=$IMAGE:buildcache-$ARCHalways,--cache-toonly on pipelines that hold push credentials. - Push is enabled on
v*tag pipelines and on manual (web) runs with aPUSH: "true"variable. MR pipelines never push.
Trivy on GitLab
- The official Trivy image, pinned to an exact version.
TRIVY_CACHE_DIR: $CI_PROJECT_DIR/.cache/trivywith acache:on that path, becausecache:only saves paths inside the project directory. - The reporting scan runs first, with
--exit-code 0, then the gate (--exit-code 1 --severity HIGH,CRITICAL --ignore-unfixed). Reports are uploaded withartifacts: when: always. - Reports, using the templates shipped in the image (
@/contrib/…), never downloaded:- every tier:
--format template --template @/contrib/junit.tplintoartifacts: reports: junit:, which shows up in the MR widget; - Ultimate: also
@/contrib/gitlab.tplintoartifacts: reports: container_scanning:for the image. The project vulnerability report is only fed from default-branch pipelines, so the scan has to run there.
- every tier:
Schedules
Pipeline schedules live in the project settings, not in the repo, so
CONTRIBUTING.md documents each one (cron, ref, variables).
- The security schedule sets
SCHEDULE_TASK: security, and jobs select on$CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TASK == "security". Other schedules (Renovate, …) pick their own value, and every other job has awhen: neverrule forschedule. - Find the latest stable release with
git ls-remote --tags origin 'v*'rather thangit tag, since the clone is shallow. - A schedule runs as its owner and is deactivated when that user is blocked or removed. Own it with a bot or service account.
release
On $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ only. The regex is what keeps
-rcN tags from getting a release page, while build still pushes them.
release:
stage: release
needs:
- manifest
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
script:
- scripts/release-notes.sh > release-notes.md
release:
tag_name: $CI_COMMIT_TAG
description: release-notes.mdscripts/release-notes.shgets the notes from the changelog API (GET /projects/:id/repository/changelog?version=<v>&from=<previous stable tag>), called with a protected project access token withread_api.CI_JOB_TOKENonly reaches a short allowlist of endpoints.- The API groups commits by their
Changelog:git trailer (added,changed,fixed,security,deprecated,performance,removed,other), titled by.gitlab/changelog_config.yml. The trailer must be on the commit that lands on the default branch. With squash merges, that is the squash commit message, set in the MR. - The job image must carry the release tool the instance expects (
glab, orrelease-cli, deprecated since GitLab 18.0).
chart
On $CI_COMMIT_TAG =~ /^chart-\d+\.\d+\.\d+(-rc\d+)?$/ (an rc chart tag
publishes too) and manual runs: helm package --version <v> then helm push
to oci://<registry>/charts, after the same version drift guard as release
(release-script-conventions).
docs and GitLab Pages
What the pipeline does is in starlight-conventions. On GitLab:
- Any pipeline that runs a Pages job deploys, whatever its ref; there is no
environment protection to fall back on. The
rulesare the only guard. - Two jobs.
docs-buildruns on MRs touching the site (validation only) and on the default branch.pagesdeploys: a job with thepages:keyword,pages: publish: public, run on the default branch only, never on a schedule:pages: stage: deploy image: ghcr.io/jdx/mise:<mise version>-debian variables: GIT_DEPTH: 0 rules: - if: $CI_PIPELINE_SOURCE == "schedule" when: never - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "pipeline" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH changes: paths: - docs/**/* - logo.svg - .gitlab/ci/docs.yml script: - git fetch --tags --force origin - mise install --locked - mise exec -- npm ci --prefix docs - mise exec -- npm --prefix docs run build:versions - mv docs/dist public pages: publish: publicdocs-buildis the same script withoutpages:, with the MR rule instead. Before GitLab 17.9,publishis not apages:property: the job must be namedpagesand publishpublicthroughartifacts: paths:. GIT_DEPTH: 0plus an explicitgit fetch --tags: the runner's fetch refspecs do not bring the release tags, and a shallow clone sees no version.- After a stable release, deploy from the default branch, not the tag. The
releasejob's pipeline triggers one on the default branch, which arrives with$CI_PIPELINE_SOURCE == "pipeline"(hence thepagesrule above):docs: stage: release needs: - release rules: - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ trigger: project: $CI_PROJECT_PATH branch: $CI_DEFAULT_BRANCH - The URL depends on the instance and the project: a project with Pages unique
domains on (the default for a new project) gets a unique domain served at
/, others<group>.<pages-domain>/<project>, and a custom domain overrides both. Read it from the project's Pages settings before settingsite/base. - Parallel deployments (
pages: path_prefix:) are not how versions are served: every version is built into the one artifact.
Lint
- The
check-gitlab-cihook fromcheck-jsonschema, which validates against the vendored schema and understands!reference. - It doesn't resolve
include:.glab ci lintdoes, but it needs the API, so it is a manual check and not a hook.
Never
- Never use
only:/except:, and never filter a job withchangesalone. - Never set
interruptible: false. - Never include a template or component by branch, bare tag or remote URL.
- Never make publishing credentials unprotected, and never push from an MR pipeline.
- Never download a Trivy report template at run time.
- Never create a GitLab Release for a tag with a
-. - Never let a Pages job run outside the default branch.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

