在我的詹金斯管道中,我需要在SonarQube质量门上做出反应。有没有更简单的方法来实现此目的,而是在Sonar- Scanner日志中查找结果页面(例如https:// mysonarserver / sonar / api / ce / task?id = xxxx)并从那里解析JSON结果?
我使用Jenkins 2.30和SonarQube 5.3
提前致谢
使用适用于Jenkins 2.8.1的SonarQube Scanner,可以立即使用该解决方案:
stage('SonarQube analysis') { withSonarQubeEnv('My SonarQube Server') { sh 'mvn clean package sonar:sonar' } // SonarQube taskId is automatically attached to the pipeline context } } stage("Quality Gate"){ timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv if (qg.status != 'OK') { error "Pipeline aborted due to quality gate failure: ${qg.status}" } } }