Gitlab Ci Patterns
Unverified●30/40Claude Code◐PartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor◐PartialPlain prose you can paste in — but no Cursor rules file
Codex◐PartialPlain prose you can paste in — but no AGENTS.md
Gemini CLI◐PartialPlain prose you can paste in
Copilot◐PartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add gitlab-ci-patternsWho is stuck, and on what
Build GitLab CI/CD pipelines with multi-stage workflows, caching, and distributed runners for scalable automation. Use when implementing GitLab CI/CD, optimizing pipeline performance, or setting up automated testing and deployment.
The whole source
Frontmatter — 2 properties
| name | gitlab-ci-patterns |
|---|---|
| description | Build GitLab CI/CD pipelines with multi-stage workflows, caching, and distributed runners for scalable automation. Use when implementing GitLab CI/CD, optimizing pipeline performance, or setting up automated testing and deployment. |
| 1 | --- |
| 2 | name: gitlab-ci-patterns |
| 3 | description: Build GitLab CI/CD pipelines with multi-stage workflows, caching, and distributed runners for scalable automation. Use when implementing GitLab CI/CD, optimizing pipeline performance, or setting up automated testing and deployment. |
| 4 | ---A5 — No allowed-tools declared — no way to tell what this skill may touch |
| 5 | |
| 6 | # GitLab CI Patterns |
| 7 | |
| 8 | Comprehensive GitLab CI/CD pipeline patterns for automated testing, building, and deployment. |
| 9 | |
| 10 | ## Purpose |
| 11 | |
| 12 | Create efficient GitLab CI pipelines with proper stage organization, caching, and deployment strategies. |
| 13 | |
| 14 | ## When to Use |
| 15 | |
| 16 | - Automate GitLab-based CI/CD |
| 17 | - Implement multi-stage pipelines |
| 18 | - Configure GitLab Runners |
| 19 | - Deploy to Kubernetes from GitLab |
| 20 | - Implement GitOps workflows |
| 21 | |
| 22 | ## Basic Pipeline Structure |
| 23 | |
| 24 | ```yaml |
| 25 | stages: |
| 26 | - build |
| 27 | - test |
| 28 | - deploy |
| 29 | |
| 30 | variables: |
| 31 | DOCKER_DRIVER: overlay2 |
| 32 | DOCKER_TLS_CERTDIR: "/certs" |
| 33 | |
| 34 | build: |
| 35 | stage: build |
| 36 | image: node:20 |
| 37 | script: |
| 38 | - npm ci |
| 39 | - npm run build |
| 40 | artifacts: |
| 41 | paths: |
| 42 | - dist/ |
| 43 | expire_in: 1 hour |
| 44 | cache: |
| 45 | key: ${CI_COMMIT_REF_SLUG} |
| 46 | paths: |
| 47 | - node_modules/ |
| 48 | |
| 49 | test: |
| 50 | stage: test |
| 51 | image: node:20 |
| 52 | script: |
| 53 | - npm ci |
| 54 | - npm run lint |
| 55 | - npm test |
| 56 | coverage: '/Lines\s*:\s*(\d+\.\d+)%/' |
| 57 | artifacts: |
| 58 | reports: |
| 59 | coverage_report: |
| 60 | coverage_format: cobertura |
| 61 | path: coverage/cobertura-coverage.xml |
| 62 | |
| 63 | deploy: |
| 64 | stage: deploy |
| 65 | image: bitnami/kubectl:1.31 |
| 66 | script: |
| 67 | - kubectl apply -f k8s/ |
| 68 | - kubectl rollout status deployment/my-app |
| 69 | only: |
| 70 | - main |
| 71 | environment: |
| 72 | name: production |
| 73 | url: https://app.example.com |
| 74 | ``` |
| 75 | |
| 76 | ## Docker Build and Push |
| 77 | |
| 78 | ```yaml |
| 79 | build-docker: |
| 80 | stage: build |
| 81 | image: docker:24 |
| 82 | services: |
| 83 | - docker:24-dind |
| 84 | before_script: |
| 85 | - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY |
| 86 | script: |
| 87 | - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . |
| 88 | - docker build -t $CI_REGISTRY_IMAGE:latest . |
| 89 | - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA |
| 90 | - docker push $CI_REGISTRY_IMAGE:latest |
| 91 | only: |
| 92 | - main |
| 93 | - tags |
| 94 | ``` |
| 95 | |
| 96 | ## Multi-Environment Deployment |
| 97 | |
| 98 | ```yaml |
| 99 | .deploy_template: &deploy_template |
| 100 | image: bitnami/kubectl:1.31 |
| 101 | before_script: |
| 102 | - kubectl config set-cluster k8s --server="$KUBE_URL" --insecure-skip-tls-verify=true |
| 103 | - kubectl config set-credentials admin --token="$KUBE_TOKEN" |
| 104 | - kubectl config set-context default --cluster=k8s --user=admin |
| 105 | - kubectl config use-context default |
| 106 | |
| 107 | deploy:staging: |
| 108 | <<: *deploy_template |
| 109 | stage: deploy |
| 110 | script: |
| 111 | - kubectl apply -f k8s/ -n staging |
| 112 | - kubectl rollout status deployment/my-app -n staging |
| 113 | environment: |
| 114 | name: staging |
| 115 | url: https://staging.example.com |
| 116 | only: |
| 117 | - develop |
| 118 | |
| 119 | deploy:production: |
| 120 | <<: *deploy_template |
| 121 | stage: deploy |
| 122 | script: |
| 123 | - kubectl apply -f k8s/ -n production |
| 124 | - kubectl rollout status deployment/my-app -n production |
| 125 | environment: |
| 126 | name: production |
| 127 | url: https://app.example.com |
| 128 | when: manual |
| 129 | only: |
| 130 | - main |
| 131 | ``` |
| 132 | |
| 133 | ## Terraform Pipeline |
| 134 | |
| 135 | ```yaml |
| 136 | stages: |
| 137 | - validate |
| 138 | - plan |
| 139 | - apply |
| 140 | |
| 141 | variables: |
| 142 | TF_ROOT: ${CI_PROJECT_DIR}/terraform |
| 143 | TF_VERSION: "1.6.0" |
| 144 | |
| 145 | before_script: |
| 146 | - cd ${TF_ROOT} |
| 147 | - terraform --version |
| 148 | |
| 149 | validate: |
| 150 | stage: validate |
| 151 | image: hashicorp/terraform:${TF_VERSION} |
| 152 | script: |
| 153 | - terraform init -backend=false |
| 154 | - terraform validate |
| 155 | - terraform fmt -check |
| 156 | |
| 157 | plan: |
| 158 | stage: plan |
| 159 | image: hashicorp/terraform:${TF_VERSION} |
| 160 | script: |
| 161 | - terraform init |
| 162 | - terraform plan -out=tfplan |
| 163 | artifacts: |
| 164 | paths: |
| 165 | - ${TF_ROOT}/tfplan |
| 166 | expire_in: 1 day |
| 167 | |
| 168 | apply: |
| 169 | stage: apply |
| 170 | image: hashicorp/terraform:${TF_VERSION} |
| 171 | script: |
| 172 | - terraform init |
| 173 | - terraform apply -auto-approve tfplan |
| 174 | dependencies: |
| 175 | - plan |
| 176 | when: manual |
| 177 | only: |
| 178 | - main |
| 179 | ``` |
| 180 | |
| 181 | ## Security Scanning |
| 182 | |
| 183 | ```yaml |
| 184 | include: |
| 185 | - template: Security/SAST.gitlab-ci.yml |
| 186 | - template: Security/Dependency-Scanning.gitlab-ci.yml |
| 187 | - template: Security/Container-Scanning.gitlab-ci.yml |
| 188 | |
| 189 | trivy-scan: |
| 190 | stage: test |
| 191 | image: aquasec/trivy:0.58.0 |
| 192 | script: |
| 193 | - trivy image --exit-code 1 --severity HIGH,CRITICAL $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA |
| 194 | allow_failure: true |
| 195 | ``` |
| 196 | |
| 197 | ## Caching Strategies |
| 198 | |
| 199 | ```yaml |
| 200 | # Cache node_modules |
| 201 | build: |
| 202 | cache: |
| 203 | key: ${CI_COMMIT_REF_SLUG} |
| 204 | paths: |
| 205 | - node_modules/ |
| 206 | policy: pull-push |
| 207 | |
| 208 | # Global cache |
| 209 | cache: |
| 210 | key: ${CI_COMMIT_REF_SLUG} |
| 211 | paths: |
| 212 | - .cache/ |
| 213 | - vendor/ |
| 214 | |
| 215 | # Separate cache per job |
| 216 | job1: |
| 217 | cache: |
| 218 | key: job1-cache |
| 219 | paths: |
| 220 | - build/ |
| 221 | |
| 222 | job2: |
| 223 | cache: |
| 224 | key: job2-cache |
| 225 | paths: |
| 226 | - dist/ |
| 227 | ``` |
| 228 | |
| 229 | ## Dynamic Child Pipelines |
| 230 | |
| 231 | ```yaml |
| 232 | generate-pipeline: |
| 233 | stage: build |
| 234 | script: |
| 235 | - python generate_pipeline.py > child-pipeline.yml |
| 236 | artifacts: |
| 237 | paths: |
| 238 | - child-pipeline.yml |
| 239 | |
| 240 | trigger-child: |
| 241 | stage: deploy |
| 242 | trigger: |
| 243 | include: |
| 244 | - artifact: child-pipeline.yml |
| 245 | job: generate-pipeline |
| 246 | strategy: depend |
| 247 | ``` |
| 248 | |
| 249 | |
| 250 | ## Best Practices |
| 251 | |
| 252 | 1. **Use specific image tags** (node:20, not node:latest) |
| 253 | 2. **Cache dependencies** appropriately |
| 254 | 3. **Use artifacts** for build outputs |
| 255 | 4. **Implement manual gates** for production |
| 256 | 5. **Use environments** for deployment tracking |
| 257 | 6. **Enable merge request pipelines** |
| 258 | 7. **Use pipeline schedules** for recurring jobs |
| 259 | 8. **Implement security scanning** |
| 260 | 9. **Use CI/CD variables** for secrets |
| 261 | 10. **Monitor pipeline performance** |
| 262 | |
| 263 | ## Related Skills |
| 264 | |
| 265 | - `github-actions-templates` - For GitHub Actions |
| 266 | - `deployment-pipeline-design` - For architecture |
| 267 | - `secrets-management` - For secrets handling |
| 268 |
Reviews
Installed this one?Write the first review and take the Trailblazer badge.
Alternatives
Paper Poster (HTML): measurement-gated poster generationDEFAULT poster pipeline — build an academic conference poster (ICML/NeurIPS/ICLR/CVPR/...) as a single HTML/CSS file with measurement-driven hard gates, real paper figures, a two-hue design-token system, and print-ready PDF via headless Chromium. Use when the●····●36/40Brand Monitoring 📡Brand monitoring tool for tracking mentions across social media platforms. Monitor Reddit, Google News, YouTube, and DuckDuckGo for brand mentions. Includes sentiment analysis, trend tracking, crisis detection, and competitor comparison. No API key required fo◐····●34/40Spark Memory & Thermal OpsManage unified memory and thermals during long-running ML jobs on NVIDIA DGX Spark. Use when planning memory headroom for a training run on GB10, when a job OOMs on unified memory, or when monitoring temperature and power during multi-hour training.◐····●32/40Secrets ManagementImplement secure secrets management for CI/CD pipelines using Vault, AWS Secrets Manager, or native platform solutions. Use when handling sensitive credentials, rotating secrets, or securing CI/CD environments.◐····●32/40