[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-bf42d7a0-01f1-4dc8-9357-63a7dc69cfa9":3,"$fiDcOlSUV5V1lndEKe-INGBgJlUT5bBO_nJ4Bzly6KA0":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"bf42d7a0-01f1-4dc8-9357-63a7dc69cfa9","gitlab-ci-patterns","全面的GitLab CI\u002FCD流水线模式，用于自动化测试、构建和部署。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: gitlab-ci-patterns\ndescription: \"Comprehensive GitLab CI\u002FCD pipeline patterns for automated testing, building, and deployment.\"\nrisk: critical\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# GitLab CI Patterns\n\nComprehensive GitLab CI\u002FCD pipeline patterns for automated testing, building, and deployment.\n\n## Do not use this skill when\n\n- The task is unrelated to gitlab ci patterns\n- You need a different domain or tool outside this scope\n\n## Instructions\n\n- Clarify goals, constraints, and required inputs.\n- Apply relevant best practices and validate outcomes.\n- Provide actionable steps and verification.\n- If detailed examples are required, open `resources\u002Fimplementation-playbook.md`.\n\n## Purpose\n\nCreate efficient GitLab CI pipelines with proper stage organization, caching, and deployment strategies.\n\n## Use this skill when\n\n- Automate GitLab-based CI\u002FCD\n- Implement multi-stage pipelines\n- Configure GitLab Runners\n- Deploy to Kubernetes from GitLab\n- Implement GitOps workflows\n\n## Basic Pipeline Structure\n\n```yaml\nstages:\n  - build\n  - test\n  - deploy\n\nvariables:\n  DOCKER_DRIVER: overlay2\n  DOCKER_TLS_CERTDIR: \"\u002Fcerts\"\n\nbuild:\n  stage: build\n  image: node:20\n  script:\n    - npm ci\n    - npm run build\n  artifacts:\n    paths:\n      - dist\u002F\n    expire_in: 1 hour\n  cache:\n    key: ${CI_COMMIT_REF_SLUG}\n    paths:\n      - node_modules\u002F\n\ntest:\n  stage: test\n  image: node:20\n  script:\n    - npm ci\n    - npm run lint\n    - npm test\n  coverage: '\u002FLines\\s*:\\s*(\\d+\\.\\d+)%\u002F'\n  artifacts:\n    reports:\n      coverage_report:\n        coverage_format: cobertura\n        path: coverage\u002Fcobertura-coverage.xml\n\ndeploy:\n  stage: deploy\n  image: bitnami\u002Fkubectl:latest\n  script:\n    - kubectl apply -f k8s\u002F\n    - kubectl rollout status deployment\u002Fmy-app\n  only:\n    - main\n  environment:\n    name: production\n    url: https:\u002F\u002Fapp.example.com\n```\n\n## Docker Build and Push\n\n```yaml\nbuild-docker:\n  stage: build\n  image: docker:24\n  services:\n    - docker:24-dind\n  before_script:\n    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY\n  script:\n    - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .\n    - docker build -t $CI_REGISTRY_IMAGE:latest .\n    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA\n    - docker push $CI_REGISTRY_IMAGE:latest\n  only:\n    - main\n    - tags\n```\n\n## Multi-Environment Deployment\n\n```yaml\n.deploy_template: &deploy_template\n  image: bitnami\u002Fkubectl:latest\n  before_script:\n    - kubectl config set-cluster k8s --server=\"$KUBE_URL\" --insecure-skip-tls-verify=true\n    - kubectl config set-credentials admin --token=\"$KUBE_TOKEN\"\n    - kubectl config set-context default --cluster=k8s --user=admin\n    - kubectl config use-context default\n\ndeploy:staging:\n  \u003C\u003C: *deploy_template\n  stage: deploy\n  script:\n    - kubectl apply -f k8s\u002F -n staging\n    - kubectl rollout status deployment\u002Fmy-app -n staging\n  environment:\n    name: staging\n    url: https:\u002F\u002Fstaging.example.com\n  only:\n    - develop\n\ndeploy:production:\n  \u003C\u003C: *deploy_template\n  stage: deploy\n  script:\n    - kubectl apply -f k8s\u002F -n production\n    - kubectl rollout status deployment\u002Fmy-app -n production\n  environment:\n    name: production\n    url: https:\u002F\u002Fapp.example.com\n  when: manual\n  only:\n    - main\n```\n\n## Terraform Pipeline\n\n```yaml\nstages:\n  - validate\n  - plan\n  - apply\n\nvariables:\n  TF_ROOT: ${CI_PROJECT_DIR}\u002Fterraform\n  TF_VERSION: \"1.6.0\"\n\nbefore_script:\n  - cd ${TF_ROOT}\n  - terraform --version\n\nvalidate:\n  stage: validate\n  image: hashicorp\u002Fterraform:${TF_VERSION}\n  script:\n    - terraform init -backend=false\n    - terraform validate\n    - terraform fmt -check\n\nplan:\n  stage: plan\n  image: hashicorp\u002Fterraform:${TF_VERSION}\n  script:\n    - terraform init\n    - terraform plan -out=tfplan\n  artifacts:\n    paths:\n      - ${TF_ROOT}\u002Ftfplan\n    expire_in: 1 day\n\napply:\n  stage: apply\n  image: hashicorp\u002Fterraform:${TF_VERSION}\n  script:\n    - terraform init\n    - terraform apply -auto-approve tfplan\n  dependencies:\n    - plan\n  when: manual\n  only:\n    - main\n```\n\n## Security Scanning\n\n```yaml\ninclude:\n  - template: Security\u002FSAST.gitlab-ci.yml\n  - template: Security\u002FDependency-Scanning.gitlab-ci.yml\n  - template: Security\u002FContainer-Scanning.gitlab-ci.yml\n\ntrivy-scan:\n  stage: test\n  image: aquasec\u002Ftrivy:latest\n  script:\n    - trivy image --exit-code 1 --severity HIGH,CRITICAL $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA\n  allow_failure: true\n```\n\n## Caching Strategies\n\n```yaml\n# Cache node_modules\nbuild:\n  cache:\n    key: ${CI_COMMIT_REF_SLUG}\n    paths:\n      - node_modules\u002F\n    policy: pull-push\n\n# Global cache\ncache:\n  key: ${CI_COMMIT_REF_SLUG}\n  paths:\n    - .cache\u002F\n    - vendor\u002F\n\n# Separate cache per job\njob1:\n  cache:\n    key: job1-cache\n    paths:\n      - build\u002F\n\njob2:\n  cache:\n    key: job2-cache\n    paths:\n      - dist\u002F\n```\n\n## Dynamic Child Pipelines\n\n```yaml\ngenerate-pipeline:\n  stage: build\n  script:\n    - python generate_pipeline.py > child-pipeline.yml\n  artifacts:\n    paths:\n      - child-pipeline.yml\n\ntrigger-child:\n  stage: deploy\n  trigger:\n    include:\n      - artifact: child-pipeline.yml\n        job: generate-pipeline\n    strategy: depend\n```\n\n## Reference Files\n\n- `assets\u002Fgitlab-ci.yml.template` - Complete pipeline template\n- `references\u002Fpipeline-stages.md` - Stage organization patterns\n\n## Best Practices\n\n1. **Use specific image tags** (node:20, not node:latest)\n2. **Cache dependencies** appropriately\n3. **Use artifacts** for build outputs\n4. **Implement manual gates** for production\n5. **Use environments** for deployment tracking\n6. **Enable merge request pipelines**\n7. **Use pipeline schedules** for recurring jobs\n8. **Implement security scanning**\n9. **Use CI\u002FCD variables** for secrets\n10. **Monitor pipeline performance**\n\n## Related Skills\n\n- `github-actions-templates` - For GitHub Actions\n- `deployment-pipeline-design` - For architecture\n- `secrets-management` - For secrets handling\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,212,1717,"2026-05-16 13:20:39",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"7b6a722f-29e7-47ff-ad30-2de3575c3fa2","1.0.0","gitlab-ci-patterns.zip",2407,"uploads\u002Fskills\u002Fbf42d7a0-01f1-4dc8-9357-63a7dc69cfa9\u002Fgitlab-ci-patterns.zip","16ec320842d931976058db34a2c5824ba9bd66125f6741e472187089be73d1a5","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":6213}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]