[英]How to receive quality gate status from SonarQube in Jenkins pipeline?
For the below pipeline script:对于以下管道脚本:
stage('stage1'){
withSonarQubeEnv(server){
sh "${scannerHome}/bin/sonar-scanner"
}
}
stage1
launches Sonar scan and exit with success state. stage1
启动声纳扫描并以成功状态退出。
stage2
waits for 30 minutes until sonar scan completes, jenkins is suppose to receive QualityGate status, as per below code. stage2
等待 30 分钟,直到声纳扫描完成,jenkins 假设按照以下代码接收 QualityGate 状态。
stage('stage2'){
timeout(time: 40, unit: 'MINUTES') {
def qGate = waitForQualityGate()
if (qGate.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qGate.status}"
}
}
}
We have Sonar server and sonar scanner configured in Jenkins.我们在 Jenkins 中配置了声纳服务器和声纳扫描仪。
Is there additional configuration required to receive quality gate status?是否需要额外的配置来接收质量门状态?
To make it work you need:要使其工作,您需要:
withSonarQubeEnv(nameofyourconfiguredSonarHost)
work withSonarQubeEnv(nameofyourconfiguredSonarHost)
工作 After that it should work as expected.之后它应该按预期工作。 In my experience a timeout of 10 mins is sufficient.
根据我的经验,10 分钟的超时就足够了。
Maybe there are additional settings needed, ie proxy or firewall to be able to access Jenkins from Sonarqube - it depends on your network.也许需要其他设置,即代理或防火墙才能从 Sonarqube 访问 Jenkins - 这取决于您的网络。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.