【发布时间】:2021-01-31 02:59:05
【问题描述】:
我有兴趣为我的项目添加质量门。在 Jenkins 构建后,我添加了一个脚本,该脚本在 SonarQube 服务器上创建一个项目并确定测试质量是否足够(可以找到代码来源here)。脚本如下
stage('SonarCloud') {
steps {
withSonarQubeEnv('SonarQube') {
sh 'mvn clean package sonar:sonar '
}
}
}
stage("Quality Gate") {
steps {
timeout(time: 15, unit: 'MINUTES') { // If analysis takes longer than indicated time, then build will be aborted
waitForQualityGate abortPipeline: true
script{
def qg = waitForQualityGate() // Waiting for analysis to be completed
if(qg.status != 'OK'){ // If quality gate was not met, then present error
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
问题是我的构建永远不会自行完成(它在超时后中止。删除超时使它看起来永远运行。话虽如此,分析被创建并放置在 SonarQube 服务器上)。这是我在超时之前看到的消息:
SonarQube 任务“AXUx0uqFm6myUuXQbknO”状态为“IN_PROGRESS”
由于超时而取消嵌套步骤
我的问题是我不是 SonarQube 服务器的管理员,所以我无法添加可以解决此问题的 webhook。我想知道是否有解决方法?
我尝试替换
sh 'mvn clean package sonar:sonar '
与
sh 'mvn clean package sonar:sonar -Dsonar.webhooks.project=https://my-jenkins-server.com/sonarqube-webhook/'
但没有到达任何地方。
我也尝试改编this code,在类似问题中讨论过,但也没有走远。
【问题讨论】:
标签: sonarqube jenkins-pipeline multibranch-pipeline