stages: - job - analysis sonarqube-check: stage: job image: name: sonarsource/sonar-scanner-cli:latest 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 cache: key: "${CI_JOB_NAME}" paths: - .sonar/cache script: - cat sonar-project.properties - sonar-scanner -Dsonar.projectBaseDir=${CI_PROJECT_DIR} allow_failure: true rules: - if: $CI_PIPELINE_SOURCE == "schedule" quality_gate: stage: analysis image: name: badouralix/curl-jq entrypoint: [""] script: - testResult="$(curl -s -u $SONAR_TOKEN $SONAR_HOST_URL/api/qualitygates/project_status?projectKey=term-structure-sdk-dev | jq)" - result=$(echo $testresult | jq -e '.projectStatus.status=="ERROR"') - PROJECT_STATUS=$(echo $testresult | jq -r '.projectStatus.status') - RELIABLITY_RATING=$(echo $testresult | jq -r '.projectStatus.conditions[0].status') - SECURITY_RATING=$(echo $testresult | jq -r '.projectStatus.conditions[1].status') - MAINTAINABILITY_RATING=$(echo $testresult | jq -r '.projectStatus.conditions[2].status') - COVERAGE=$(echo $testresult | jq -r '.projectStatus.conditions[3].actualValue') - DUPLICATED_LINE_DENSITY=$(echo $testresult | jq -r '.projectStatus.conditions[5].actualValue') - $result && curl -X POST --location "${SLACK_WEBHOOK_URL}" --header "Content-Type:application/json" --data '{"text":"{\"projectStatus\":\"ERROR\",\"projectName\":\"term-structure-sdk-dev\"}"}' rules: - if: $CI_PIPELINE_SOURCE == "schedule"