Jenkins Gerrit 报告值插件删除了代码审查的值

米兰巴拉兹

我有一个包含两个步骤的流水线脚本。

  • SonarQube 分析
  • UnitTests

如果SonarQube发现警告,它会将它们作为评论报告给 Gerrit 并设置Code-review-1. 下一阶段是 UnitTest,如果没问题,Pipeline 将成功,Jenkins 应向 Gerrit 报告Verified+1但是,当 Jenkins 报告时,Verified+1它会删除Code-review-1.

我的管道脚本的相关部分:

....
stage('SonarQube') {
            steps {
                ....
                    ....
                            scoreConfig: [
                                issueFilterConfig: [
                                    severity: 'INFO', 
                                    newIssuesOnly: false, 
                                    changedLinesOnly: false
                                    ], 
                                category: 'Code-Review', 
                                noIssuesScore: 0,
                                issuesScore: -1
                            ]
                     ....
        }
        stage('UnitTest') {
            steps {
                ansiColor('xterm') {
                    sh '''./unittest.sh'''
                }
      ....

我的“Gerrit 报告价值”部分:

Gerrit 报告价值部分

我的 Gerrit 历史:

格里特历史

我的最终结果:

最后结果

我的问题:

How can I set the the Code-review-1 and Verified+1 in one running? How can I avoid that Gerrit removes the Code-review-1 when reports Verified+1? I am open to GUI solution as well as Pipeline.

EDIT:

It is not option to change the global config of Gerrit plugin. I have to solve it on Jenkins job level. Is it possible?

milanbalazs

First of all, as I mentioned in my question the global Gerrit config change and new Gerrit server were not option for me. I needed to solve this problem on Jenkins job level.

I have found a "solution" which is rather a work-around, but it works.

Step 0:

如果您检查STDOUTSonarQubeJenkins控制台日志,你可以看到这表明,它们被影响分数计算的问题数量的特定行。这一行是:Issues to be involved in score calculation: X这意味着您可以根据此行知道是否存在受影响的问题。

詹金斯控制台日志

第1步:

您应该检查Jenkins控制台日志并找到分数计算中涉及的问题数量。你可以在下面看到我的实现。如果存在问题(RegEx值不为零),则此阶段应将构建结果设置为UNSTABLE

stage('Results') {
            steps {
                script{
                        for(String line : currentBuild.getRawBuild().getLog(30)){
                            def find_pattern = (line =~ /^Issues to be involved in score calculation: [1-9]/)
                            if(find_pattern){
                                echo line
                                echo "Sonar has found warnings in changed lines. Build goes to UNSTABLE."
                                currentBuild.result = "UNSTABLE"
                            }
                        }
                    }

它如何工作的示例输出:

Report has loaded and contains 1021 issues
Issues to be commented: 1
Issues to be involved in score calculation: 1
Review has been sent
[Pipeline] }
[Pipeline] // withSonarQubeEnv
[Pipeline] }
[Pipeline] // ansiColor
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Results)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Issues to be involved in score calculation: 1
[Pipeline] echo
Sonar has found warnings in changed lines. Build goes to UNSTABLE.

第2步:

配置Gerrit Reporting Values块以GerritUNSTABLE构建结果的情况下报告两个值(CR 和验证标签)

enter image description here

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Jenkins Gerrit触发器插件提供了已编码的GERRIT_CHANGE_COMMIT_MESSAGE和GERRIT_EVENT_COMMENT_TEXT

无法通过 jenkins 向 gerrit 服务器报告 +1

Jenkins:Gerrit&Git插件-缺少refspec字段?

Gerrit 代码审查

如何在Gerrit Jenkins触发器中禁用默认代码审阅值?

如何在不使用 Gerrit 插件的情况下将评分从 Jenkins 发回 Gerrit 服务器

Gerrit 代码审查多次提交

Jenkins Gerrit触发器插件的“禁止文件路径”的确切使用

如何在jenkins git插件中下载一个特定的Gerrit更改集?

如何使用gerrit触发器插件在Jenkins中执行Jenkinsfile的变更集?

如何在Jenkinsfile内的Jenkins管道代码内添加gerrit-trigger事件

Jenkins Gerrit-trigger 发表评论

从Gerrit / Git填充Jenkins工作区

Jenkins和Gerrit与Google Repo SCM集成

Jenkins + Git/Gerrit + 增量 Klocwork 扫描

Gerrit & Jenkins 管道最新变化

Gerrit插件/ Jira集成?

Gerrit构建来自Jenkins中构建后操作的发布评论

Gerrit + Jenkins:传达非阻塞性工作的结果?

Jenkins无法连接到gerrit存储库(Windows安装)

Jenkins 管道无法使用凭据推送到 gerrit

Gerrit无法加载“正在启动Gerrit代码审查:失败”,日志中没有错误

如何从Git GUI推送提交到Gerrit上的代码审查?

Gerrit-重新加载插件以合并更改

如何在Gerrit插件中使用LifecycleListener?

让特定的审阅者审阅gerrit上的代码

使用Gerrit触发器启动Jenkins管道-正则表达式

Jenkins Gerrit触发器在构建时未获取我的更改

如何从jenkins gerrit触发器发布自定义标签上的投票?