SonarQube and GitLab CI/CD are a common pairing in a modern DevOps stack. Here is how they fit together and a practical way to wire them up.
Where SonarQube fits
SonarQube statically analyzes code for bugs, vulnerabilities, security hotspots and 'code smells', and enforces a Quality Gate in CI so problematic changes fail the build.
# sonar-project.properties
sonar.projectKey=acme-web
sonar.sources=src
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.qualitygate.wait=trueWhere 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"' }]Making them work together
- Enforce a 'new code' Quality Gate on every PR
- Wire coverage reports into the scan
- Use stages and needs: for a fast DAG pipeline
- Cache dependencies and pass build output as artifacts
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 SonarQube and GitLab CI/CD have active community groups you can join for free.