Created
September 28, 2021 04:54
-
-
Save avarne/cf151e6eecb88c1c27d0e1ff0b4d9136 to your computer and use it in GitHub Desktop.
GitLab CI pipeline to execute SonarQube Scan using maven and checking status using Sonar REST api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- codequality | |
sonar-check: | |
stage: codequality | |
tags: | |
- demo | |
script: | |
- echo "codequality started for project" | |
- export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64/ && export PATH=$JAVA_HOME/bin:$PATH | |
- mvn clean package sonar:sonar -Dproject.settings=sonar.properties -Dsonar.projectKey=$CI_PROJECT_NAME -Dsonar.projectName=acm-client-sdk -Dmaven.test.skip=true | |
- echo "codequality finised for project checking for qualitydate" | |
- sleep 10s | |
- result=$(curl http://sonarqube.com:9000/api/qualitygates/project_status?projectKey=$CI_PROJECT_NAME) | |
- echo $result | if [ $(python -c 'import sys, json; print json.load(sys.stdin)["projectStatus"]["status"]') == "ERROR" ]; then exit 1; else echo "Sonar quality gate passed"; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment