简体   繁体   English

如何将 SonarQube 分析的质量门检查到作业中

[英]How to check the quality gate of a SonarQube analysis into a job

I'm working on a jenkins job without the possibility of using a pipeline.我正在从事詹金斯的工作,但不可能使用管道。

What i need to do is to launch some sonarQube Analysis and to check if the quality gates has passed.我需要做的是启动一些 sonarQube 分析并检查质量门是否已经通过。 If the analysis with the quality gate fails, i would like to block my job.如果质量门的分析失败,我想阻止我的工作。

I know that i can do this by scripting a pipeline and i know how to do it, but in this particular case i cannot write a pipeline but i can use only the "Prebuild steps" and "After Build Steps" of the job.我知道我可以通过编写管道脚本来做到这一点,我知道如何做到这一点,但在这种特殊情况下,我无法编写管道,但我只能使用作业的“预构建步骤”和“构建后步骤”。 So my questions are:所以我的问题是:

  • Is possibile to implment the pipeline into the job that doesn't have the pipeline section?是否可以将管道实施到没有管道部分的工作中?
  • how can i check if the analysis have passed the quality gate?我如何检查分析是否通过了质量门? I've also read about a Jenkins plugin called "Quality Gate", but it has a problem about security (credentials in plain text) so i think they will not allow me to use it.我还读过一个名为“Quality Gate”的 Jenkins 插件,但它存在安全问题(纯文本凭据),所以我认为他们不会允许我使用它。

Thanks everybody!谢谢大家!

In this case probably the easiest thing would be to instruct sonar-scanner to wait for quality gate result.在这种情况下,最简单的方法可能是指示声纳扫描仪等待质量门结果。 From the documentation :文档

you can use the sonar.qualitygate.wait=true analysis parameter in your configuration file.您可以在配置文件中使用sonar.qualitygate.wait=true分析参数。 Setting sonar.qualitygate.wait to true forces the analysis step to poll your SonarQube instance until the Quality Gate status is available.sonar.qualitygate.wait设置为 true 会强制分析步骤轮询您的 SonarQube 实例,直到 Quality Gate 状态可用。 This increases the pipeline duration and causes the analysis step to fail any time the Quality Gate fails, even if the actual analysis is successful.这会增加管道持续时间并导致分析步骤在质量门失败时失败,即使实际分析成功也是如此。

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

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