/cicd-tooling-skills:gitlab-cicd-pipeline-designfrom cicd-tooling-skills
Authors and troubleshoots .gitlab-ci.yml pipelines: stages, rules: syntax, includes for shared templates, and GitLab runner/executor configuration.
Ships in cicd-tooling-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
GitLab CI/CD pipelines are defined entirely in one file, .gitlab-ci.yml,
executed by GitLab Runners (shared, group, or project-specific) against a
stages:/rules: model that differs in specifics from GitHub Actions or
Jenkins even though the underlying pipeline concepts overlap (see
ci-cd-pipeline-design
for the vendor-neutral version). This skill covers GitLab-specific
mechanics: the stages:/rules: trigger model (and why rules: has
superseded the legacy only:/except:), include: for sharing pipeline
templates across projects, and runner/executor configuration
specifics.
.gitlab-ci.yml, or an existing one has a
job that isn't running (or runs) when expected.only:/except: job keywords to the modern rules:
syntax.include: (local,
project, remote, or template includes) rather than duplicating YAML.pending (no runner picks it up) or fails
only on certain runners.merge_request_event) alongside
branch/tag pipelines without running both redundantly on the same
commit.rules: keyword and modern workflow:
block are fully mature from GitLab 13+, but 15+ is assumed here for
current defaults and deprecation warnings around only:/except:.shell, docker,
docker+machine, kubernetes) — job tags: must match a runner's
configured tags or the job stays pending forever.include: of remote/template files: network access from the GitLab
instance to the include source (for include: remote:), or access to
the referenced project (for include: project:).Declare stages: explicitly — job execution order follows stage
order, and jobs within the same stage run in parallel by default:
stages:
- lint
- test
- build
- deploy
Use workflow: to control whether a pipeline runs at all, before
worrying about individual job rules — this avoids running duplicate
pipelines for the same commit (once as a branch pipeline, once as a
merge-request pipeline):
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_COMMIT_TAG'
Use rules: on each job, not the legacy only:/except:. rules:
evaluates a list of conditions top-to-bottom and uses the first match,
supporting changes:, if:, and exists: in combination —
expressiveness only:/except: can't match:
deploy-staging:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
changes:
- src/**/*
script:
- ./deploy.sh staging
only:/except: still parses and runs in current GitLab, but new
pipelines should use rules: — it's the only mechanism that gets new
condition types going forward, and mixing both styles in the same
project is a common source of confusing, hard-to-predict trigger
behavior.
Use changes: for monorepo path filtering so an unrelated change
doesn't trigger a full pipeline:
test-backend:
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- backend/**/*
script:
- cd backend && npm ci && npm test
Share pipeline templates across projects with include: —
local for same-repo files, project/remote for cross-repo/
cross-instance shared templates, template for GitLab's built-in
templates:
include:
- project: 'platform/ci-templates'
ref: 'v2.1.0'
file: '/templates/node-service.yml'
- local: '/.gitlab/ci/deploy.yml'
Pin ref: to a tag for a project: include, the same versioning
discipline as a Jenkins shared library or GitHub Actions reusable
workflow — an unpinned ref: main include means every consumer's
pipeline changes the moment the template repo's main branch changes.
Configure caching keyed on lockfile hash, scoped per-job or shared:
test:
stage: test
cache:
key:
files: [package-lock.json]
paths:
- node_modules/
script:
- npm ci
- npm test
Match tags: to actual runner capabilities — a job with
tags: [docker, linux] only runs on a runner registered with both
tags; a mismatch leaves the job pending indefinitely with no error
message beyond the pending state itself:
build:
stage: build
tags: [docker]
script:
- docker build -t myapp:$CI_COMMIT_SHORT_SHA .
Gate production deploys with environment: and when: manual,
giving GitLab's UI a visible "play" button and (with a protected
environment) restricting who can trigger it:
deploy-production:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: manual
environment:
name: production
url: https://app.example.com
script:
- ./deploy.sh production
rules: across the project; don't mix only:/except:
and rules: in the same .gitlab-ci.yml — the interaction between the
two legacy and modern mechanisms on different jobs is a frequent source
of "why did this job run/not run" confusion.workflow:rules once at the top of the file to prevent duplicate
branch + merge-request pipelines firing for the same commit, rather than
trying to fix it job-by-job.include: refs to tags for cross-project templates; treat the
template repo like any other shared library with semantic versioning
and a changelog.when: manual together for production deploys — when: manual alone
only adds a button, it doesn't restrict who can press it without a
protected environment's approval rules.needs: to express real job dependencies within/across stages for
a DAG-style pipeline (jobs start as soon as their specific needs: are
done, not only after the whole previous stage finishes) when
stage-by-stage sequencing is unnecessarily slow.artifacts: reports: junit: so failures surface
in the merge request UI directly rather than only in job logs.Symptom: A job that should run on merge requests runs twice — once
as a "detached" merge request pipeline, once again as a branch pipeline
after merge, and both look like separate, sometimes contradictory
states in the merge request widget.
Fix: Add a top-level workflow:rules: block that picks exactly one
pipeline source per commit context (merge_request_event OR
$CI_COMMIT_BRANCH == "main"), rather than letting both branch and
merge-request pipelines trigger unconditionally.
Symptom: A job sits in pending status indefinitely with no runner
ever picking it up, and no clear error is shown.
Fix: Check that the job's tags: match a registered, active
runner's tags exactly (Settings → CI/CD → Runners to see available
runners and their tags) — a job with a tag no runner advertises stays
pending forever rather than failing loudly.
Symptom: Converting only: [main] to rules: - if: '$CI_COMMIT_BRANCH == "main"' changes behavior unexpectedly — the job
now also runs (or stops running) on merge request pipelines.
Fix: only:/except: and rules: have different implicit
defaults for pipeline source; when migrating, be explicit about which
CI_PIPELINE_SOURCE values a job should match rather than assuming a
1:1 semantic translation, and check pipeline behavior on both a branch
push and an MR event after migrating.
Symptom: A remote/project include: pointed at a template repo's
ref: main silently changes every consuming project's pipeline the
moment someone merges to that template repo's main.
Fix: Pin ref: to a specific tag (ref: 'v2.1.0') for any
cross-project include, and roll out template changes via a version bump
in each consumer, not a floating branch reference.
Symptom: deploy-production has when: manual but any developer
with basic project access can trigger it, bypassing an intended
approval step.
Fix: when: manual alone only adds a manual trigger button — pair
it with a protected environment (Settings → CI/CD → Environments)
restricted to specific users/groups/roles to actually gate who can
press it, mirroring the manual-approval-gate guidance in
ci-cd-pipeline-design.
Scenario: A monorepo with a backend/ and frontend/ directory needs
path-filtered pipelines (only test what changed), a shared lint template
pulled from a central templates project, and a manually-gated production
deploy restricted to a protected environment.
.gitlab-ci.yml:
stages: [lint, test, build, deploy]
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "main"'
include:
- project: 'platform/ci-templates'
ref: 'v2.1.0'
file: '/templates/eslint.yml'
test-backend:
stage: test
tags: [docker]
rules:
- changes:
- backend/**/*
cache:
key: { files: [backend/package-lock.json] }
paths: [backend/node_modules/]
script:
- cd backend && npm ci && npm test
test-frontend:
stage: test
tags: [docker]
rules:
- changes:
- frontend/**/*
cache:
key: { files: [frontend/package-lock.json] }
paths: [frontend/node_modules/]
script:
- cd frontend && npm ci && npm test
build-image:
stage: build
tags: [docker]
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
script:
- docker build -t myapp:$CI_COMMIT_SHORT_SHA .
deploy-production:
stage: deploy
tags: [docker]
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: manual
environment:
name: production
url: https://app.example.com
script:
- ./deploy.sh production $CI_COMMIT_SHORT_SHA
With production configured as a protected environment restricted to the
release-managers group, a change to only frontend/ skips
test-backend entirely, and deploy-production waits for both a main
merge and an authorized manual trigger.
include: project: shared-template pattern.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin cicd-tooling-skills13 skills in this plugin
/aws-codepipeline-and-codedeployDesigns AWS CodePipeline stage/action structure and integrates it with CodeDeploy deployment groups and appspec.yml for EC2/on-prem, ECS, or Lambda deploys. Use when the user asks to "set up CodePipeline," "add a CodeDeploy deployment group," "write an appspec.yml," "wire CodePipeline to CodeDeploy," "troubleshoot a stuck/failed CodePipeline action," or "add a manual approval action before an AWS deploy."
/azure-pipelines-yaml-and-multi-stageDesigns Azure Pipelines YAML (azure-pipelines.yml), multi-stage pipelines with environments/approvals, templates for reuse across repos, and self-hosted vs. Microsoft-hosted agent pools. Use when the user asks to "set up Azure Pipelines," "write an azure-pipelines.yml," "add a multi-stage pipeline with approvals," "create a reusable pipeline template," "configure a self-hosted agent pool," or "troubleshoot a stuck/failed Azure DevOps pipeline run."
/bamboo-pipeline-yaml-and-java-specsAuthors Atlassian Bamboo pipeline definitions using either Bamboo Specs (Java DSL, compiled and run to create/update a plan) or Bamboo's YAML specs format, covering plan/job/stage structure and how a Specs definition links to and updates a live Bamboo plan. Use when the user asks to "write a Bamboo Specs plan," "convert our Bamboo plan to code," "add a stage/job to a Bamboo build," "use Bamboo YAML specs," or "troubleshoot a Bamboo Specs plan not updating the linked plan."
/complete-cicd-pipeline-deployment-for-kubernetes-from-scratchBuilds a complete CI/CD pipeline for a Kubernetes-targeted service from an empty repo — source checkout, container image build, SCA/SAST security gates, registry push, and a deploy step that ends at a GitOps handoff (committing a new image tag to a manifests repo) rather than a direct kubectl apply or helm upgrade against the cluster. Use when the user asks to "build a full CI/CD pipeline for Kubernetes from scratch," "set up CI/CD that ends in a GitOps commit, not a cluster deploy," "wire a container build pipeline into Argo CD/Flux," or "go from an empty repo to a Kubernetes service deployed via GitOps end-to-end."
/complete-cicd-pipeline-deployment-for-serverless-from-scratchBuilds a complete CI/CD pipeline for a serverless (AWS Lambda-style) function from an empty repo — source checkout, zip/layer packaging (not a container image), SCA/SAST security gates, package upload, and a SAM/Serverless-Framework/CDK-style deploy step with alias-based canary traffic shifting, distinct from Kubernetes rollout mechanics. Use when the user asks to "build a full CI/CD pipeline for a Lambda function from scratch," "set up serverless CI/CD with canary traffic shifting," "wire SAM/Serverless Framework deploys into a pipeline," or "go from an empty repo to a function deployed with an alias-based canary."
/complete-cicd-pipeline-for-vm-based-workloads-from-scratchBuilds a complete CI/CD pipeline for a VM-based workload from an empty repo — source checkout, build, immutable machine-image baking (Packer-style AMI, not a container image or a zip), SCA/SAST security gates, and a deploy step that's either a blue-green instance-group swap or a config-management push (Ansible) to existing long-lived VMs, distinct from both container and serverless deploy mechanics. Use when the user asks to "build a full CI/CD pipeline for EC2/VM workloads from scratch," "bake an AMI in CI and roll it out blue-green," "push Ansible-managed config to existing VMs from a pipeline," or "go from an empty repo to a VM fleet deployed with a golden image and Auto Scaling Group swap."
Other plugins' skills for the same job