GitLab CI/CD and Trivy are a common pairing in a modern DevOps stack. Here is how they fit together and a practical way to wire them up.
Where GitLab CI/CD fits
GitLab CI/CD runs pipelines defined in .gitlab-ci.yml on GitLab Runners, with stages, jobs, environments and built-in DevSecOps scanning - all in one platform next to the repo.
stages: [build, test, deploy]
cache: { paths: [node_modules/] }
build:
stage: build
image: node:20
script: [npm ci, npm run build]
test:
stage: test
image: node:20
script: [npm test]
deploy:prod:
stage: deploy
script: [./deploy.sh]
environment: { name: production }
when: manual
rules: [{ if: '$CI_COMMIT_BRANCH == "main"' }]Where Trivy fits
Trivy is an open-source security scanner that finds CVEs, misconfigurations, secrets and license issues across container images, filesystems, Git repos, IaC and live Kubernetes clusters.
# trivy.yaml
severity:
- HIGH
- CRITICAL
vulnerability:
ignore-unfixed: true
exit-code: 1Making them work together
- Use stages and needs: for a fast DAG pipeline
- Cache dependencies and pass build output as artifacts
- Gate on HIGH/CRITICAL with ignore-unfixed, then tighten over time
- Scan images, IaC and filesystems - not just one surface
Want this pairing set up properly, with docs and handover? That is exactly the kind of work CodeWizard's embedded senior engineers do - and both GitLab CI/CD and Trivy have active community groups you can join for free.