<< All versions
Rules — Replacing
Skill v1.0.0
currentLLM-judged scan90/100dev-toolbelt/dev-team-agents/cicd-gitlab
──Details
PublishedOctober 21, 2026 at 11:23 AM
Content Hashsha256:5d0658702f453e59...
Git SHA95c7e45144c3
──Files
Files (1 file, 2.9 KB)
SKILL.md2.9 KBactive
SKILL.md · 141 lines · 2.9 KB
version: "1.0.0" name: cicd-gitlab description: GitLab CI — .gitlab-ci.yml for build, test, lint, and deploy.
GitLab CI/CD
File Location
.gitlab-ci.yml ← root of repository
Standard Pipeline
yaml
stages:- lint- test- build- deployvariables:IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHAPOSTGRES_DB: testPOSTGRES_USER: postgresPOSTGRES_PASSWORD: postgresPOSTGRES_HOST_AUTH_METHOD: trustdefault:image: node:20-alpinecache:key: $CI_COMMIT_REF_SLUGpaths:- node_modules/before_script:- npm cilint:stage: lintscript:- npm run linttest:stage: testservices:- postgres:16-alpinevariables:DATABASE_URL: postgres://postgres:postgres@postgres:5432/testscript:- npm testartifacts:reports:junit: test-results.xmlwhen: alwaysbuild:stage: buildimage: docker:24services:- docker:24-dindvariables:DOCKER_TLS_CERTDIR: "/certs"before_script:- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRYscript:- docker build -t $IMAGE .- docker push $IMAGEonly:- maindeploy:stage: deployenvironment:name: productionurl: https://myapp.example.combefore_script: []script:- apk add --no-cache openssh-client- eval $(ssh-agent -s)- echo "$DEPLOY_KEY" | ssh-add -- ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_HOST "cd /opt/myapp &&IMAGE_TAG=$CI_COMMIT_SHA docker compose pull app &&IMAGE_TAG=$CI_COMMIT_SHA docker compose up -d &&docker image prune -f"only:- mainwhen: manual # remove for auto-deploy
Secrets Management
- Store secrets in Settings → CI/CD → Variables
- Mark as Masked to prevent log exposure
- Mark as Protected to restrict to protected branches
- Use variable groups for shared secrets across projects (requires GitLab Premium)
Rules — Replacing only/except
yaml
deploy:rules:- if: $CI_COMMIT_BRANCH == "main"when: on_success- if: $CI_PIPELINE_SOURCE == "merge_request_event"when: never
Reusable Templates
yaml
# .gitlab/ci/test.gitlab-ci.yml.test-template: &test-templatestage: testservices:- postgres:16-alpinescript:- npm testunit-test:<<: *test-templatevariables:SUITE: unitintegration-test:<<: *test-templatevariables:SUITE: integration
Best Practices
- Use
stagesto control execution order and parallelism - Use
needs:for DAG-based pipeline — skip waiting for entire stage - Cache
node_modules/vendorwith branch-scoped keys - Use
artifacts: reports:for test results, coverage, and SAST reports - Use
environment:for deploy jobs — enables GitLab's deployment tracking - GitLab has built-in SAST/DAST — enable in Security & Compliance settings