SonarQube 中的质量门故障不会导致 Teamcity 中的构建失败 [英] Quality Gate Failure in SonarQube does not fail the build in Teamcity
问题描述
我在 TeamCity 中建立了一个 Build 项目,并将 Sonarqube 与它集成.该项目正在构建,甚至在 SonarQube 控制台中成功发布报告.但是当质量门失败时,它并没有破坏构建.我搜索并阅读了有关构建断路器的信息,但它已经被 TeamCity 的 Sonarqube 插件支持,因为本文档 https://confluence.jetbrains.com/display/TW/SonarQube+Integration
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.
推荐答案
是的,我必须使用退出状态编写自定义脚本来中断构建.我使用API来分析QG的状态.
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
这篇关于SonarQube 中的质量门故障不会导致 Teamcity 中的构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!