diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 80f9ab8ab69564c560a9ffe9350d1981c21333d1..4ae76bae245fddbb5ba8f447ac1dccb19ba7ae54 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,24 +6,37 @@ variables: stages: - test - build + - sonar sonarqube-check: + stage: sonar image: - name: sonarsource/sonar-scanner-cli:4 + name: sonarsource/sonar-scanner-cli:11 entrypoint: [""] variables: SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + GIT_STRATEGY: clone # clone the repo in sonar job runner + SONAR_URL: http://sonarqube.forge.grandlyon.com:9000 # url to use for the sonarqube server cache: key: "${CI_JOB_NAME}" paths: - .sonar/cache script: - #- 'curl -X POST -H "Login: ${SONAR_TOKEN}" ${SONAR_URL}/api/project_branches/rename?name=main&project=${CI_PROJECT_NAME}' - - sonar-scanner -Dsonar.login=${SONAR_TOKEN} -Dsonar.projectName=${CI_PROJECT_NAME} -Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.qualitygate.wait=true -Dsonar.host.url=${SONAR_URL} - allow_failure: true - only: - - main + - > + sonar-scanner + -Dsonar.login=${SONAR_TOKEN} + -Dsonar.projectName=${CI_PROJECT_NAME} + -Dsonar.projectKey=${SONAR_PROJECT_KEY} + -Dsonar.qualitygate.wait=true + -Dsonar.host.url=${SONAR_URL} + -Dsonar.sourceEncoding=UTF-8 + -Dsonar.projectBaseDir=. + -Dsonar.sources=src + -Dsonar.exclusions=**/main.ts,**/*.module.ts,**/*.spec.ts + rules: + - if: $CI_COMMIT_BRANCH == "main" + allow_failure: true tags: - build-push-to-registry