简体   繁体   English

使用Quality Gate插件在Jenkins中构建失败

[英]Failing a build in Jenkins using the Quality Gate plugin

I m trying to fail a build in my Jenkins server using the Quality Gate plugin (v2.5). 我试图使用Quality Gate插件(v2.5)在Jenkins服务器中构建失败。 In my jenkins i have installed SonarQube plugin (v2.4.4) and SonarQube Scanner v2.6.1. 在我的jenkins中,我已经安装了SonarQube插件(v2.4.4)和SonarQube Scanner v2.6.1。 I have configured a SonarQube server as well v5.6 I have defined a quality gate (for eg bugs > 10) in my server for the project which im building using my Jenkins server. 我已经配置了SonarQube服务器以及v5.6,我在服务器中为使用我的Jenkins服务器构建的项目定义了质量门(例如,错误> 10)。 I have created a freestyle job for the same in Jenkins. 我已经在詹金斯(Jenkins)创建了一个自由职业。 What i want to achieve is the build in Jenkins should fail whenever the Quality Gate requirement is not met. 我要实现的是,只要不满足Quality Gate要求,Jenkins中的构建都将失败。 I use the "Execute SonarQube Scanner" option in my build step in Jenkins and the Quality Gate option in the post build action (with my project key). 我在Jenkins的构建步骤中使用“ Execute SonarQube Scanner”选项,在后期构建操作中使用“ Quality Gate”选项(带有我的项目密钥)。 I have defined the parameters for sonar analysis in the Analysis Properties section. 我在“分析属性”部分中定义了用于声纳分析的参数。

Currently, when the quality gate threshold is not met the status changes to failed on the SonarQube server but the build is passed in Jenkins. 当前,当未达到质量门阈值时,状态会在SonarQube服务器上变为失败,但会在Jenkins中传递。 During the next execution of the same job in Jenkins the build is failed by the Quality Gate. 在詹金斯(Jenkins)中再次执行同一作业时,该构建因质量门而失败。 That is the build status is not changed in synchronization with the SonarQube server but in the following execution, 也就是说,构建状态不会与SonarQube服务器同步更改,而是在以下执行中更改:

Can you pls let me know what mi missing here ? 您能否让我知道这里缺少什么?

it's been a while since you posted this but maybe I can help at least with my understanding. 自您发布此消息已有一段时间了,但也许我至少可以帮助我理解。

In SonarQube 5.6 (don't know when this changed) the build analysis is been analysed in a background task in SonarQube. 在SonarQube 5.6(不知道何时更改)中,在SonarQube的后台任务中分析了构建分析。 So the Jenkins Build is finished after it posted the analysis to the server and the build is finished long before the background task on the SonarQube server is finished. 因此,在将分析发布到服务器之后,Jenkins Build已完成,并且在SonarQube服务器上的后台任务完成之前很久就完成了构建。

During or on the end of the background task in SonarQube it checks the QualityGate. 在SonarQube中的后台任务期间或结束时,它将检查QualityGate。

So the Jenkins plugin get's always "outdated" QualityGate status at least with SonarQube versions higher than 5.6. 因此,至少在SonarQube版本高于5.6的情况下,Jenkins插件始终处于“过时”的QualityGate状态。

It's possible to extend the Jenkins plugin and add a "wait for background task" option. 可以扩展Jenkins插件并添加“等待后台任务”选项。 Of course this would lead longer build times in Jenkins. 当然,这会导致Jenkins的构建时间更长。 This is already done in this fork of the "Quality Gates Plugin". 这已在“ Quality Gates插件”的分支中完成。

Hope this all right :-) 希望这一切都好:-)

see the also the doku here 在这里也可以看到doku

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM