Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save lioneltchami/e9e5f25effe6d0d1fef6f377285dbde5 to your computer and use it in GitHub Desktop.

Select an option

Save lioneltchami/e9e5f25effe6d0d1fef6f377285dbde5 to your computer and use it in GitHub Desktop.
.gitlab-ci.yml
stages:
- analyze
analyze:sonar:
stage: analyze
image:
name: sonarsource/sonar-scanner-cli:4.5
entrypoint: [""]
variables:
# Defines the location of the analysis task cache
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
# Shallow cloning needs to be disabled.
# See https://docs.sonarqube.org/latest/analysis/gitlab-cicd/.
GIT_DEPTH: 0
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
rules:
# SonarQube CommunityEdition only supports analyzing a single branch.
# So only run on master.
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- when: never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment