DevOps Intermediate
GitLab CI Pipeline¶
GitLab CICI/CDPipeline 3 min read
CI/CD with GitLab CI. Stages, jobs, cache, artifacts and deployment.
.gitlab-ci.yml¶
stages: [test, build, deploy]
test:
stage: test
image: node:20
cache: {paths: [node_modules/]}
script: [npm ci, npm test]
build:
stage: build
image: docker:latest
services: [docker:dind]
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
deploy:
stage: deploy
only: [main]
script:
- kubectl set image deploy/app app=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
Cache vs Artifacts¶
- Cache - speeds up jobs, best-effort
- Artifacts - passing between stages, guaranteed
Summary¶
GitLab CI - stages, environments, review apps, security scanning in one tool.
Need Help with Implementation?¶
Our team has experience designing and implementing modern architectures. We’re happy to help.