I set up a Build project in TeamCity and integrated Sonarqube with it. The project is getting build and even publish the report successfully in SonarQube console. But when the quality gate fails, it's not breaking the build. I searched and read about the build breaker, but its already supported with Sonarqube plugin of TeamCity as this document https://confluence.jetbrains.com/display/TW/SonarQube+Integration
Am I missing something to configure/or any gotcha? I tried to search a lot but didn't find any sort of proper documentation or lead on that.
Quality Gate represents the best way to implement the Clean as You Code concept by focusing on new code. ( Quality Gates | SonarQube Docs) By default, “New Code” is defined as code added or changed since the previous version. Meaning if you are refactoring your code, the refactored code is “New Code.”
Hi, We do not recommend failing your entire build. Instead, you can add a Branch Policy on your quality gate upon pull requests, and block them from merging if the Quality Gate fails.
Quality Gates are the set of conditions a project must meet before it should be pushed to further environments. Quality Gates considers all of the quality metrics for a project and assigns a passed or failed designation for that project.
Under Quality Gates, pick the Gate you wish to use as your base, click Copy, give it a name; "Copy". Choose Add Condition, choose scope (New or Overall Code), Quality Gate criteria from the drop-down options, failure threshold; "Add Condition".
Yeah I have to write a custom script using exit status to break the build. I used API to analyse the status of QG.
PROJECTKEY="%teamcity.project.id%"
QGSTATUS=`curl -s -u SONAR_TOKEN: http://SONAR_URL:9000/api/qualitygates/project_status?projectKey=$PROJECTKEY | jq '.projectStatus.status' | tr -d '"'`
if [ "$QGSTATUS" = "OK" ]
then
exit 0
elif [ "$QGSTATUS" = "ERROR" ]
then
exit 1
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With