无法设置“Sonar Gerrit” Jenkins插件 [英] Unable to set up "Sonar Gerrit" Jenkins plugin

查看:1535
本文介绍了无法设置“Sonar Gerrit” Jenkins插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试设置 Sonar Gerrit - Jenkins插件



b
  • 在为Gerrit创建补丁集时启动Jenkins作业

  • 使用git提取源代码,启动cppcheck分析并在预览模式下启动声纳分析。 li>
  • 发布建立后操作发布SonarQube问题作为Gerrit注释。

  • Jenkins分析日志的第三点。

     获得Sonar报告:[XX] .sonar\sonar-report.json 
    报告已加载并包含2950个问题
    连接到Gerrit:服务器名称:Gerrit。更改号码:297,PatchSetNumber:1
    无法发布审核:请求失败。
    构建步骤发布SonarQube问题作为Gerrit注释标记构建为失败
    完成:FAILURE


    $ b b

    Gerrit添加了评论(表示通信工作)


    生成失败
    http:jenkins.com/ job / project / 118 /:FAILURE


    我无法理解配置不正确。你知道这个问题吗?



    在Gerrit httpd_log 文件当我启动一个新的Jenkins作业时,我有以下几行。


    IP - - [26 / oct。/ 2016:14:30:08 +0200]POST / a / changes / REF / revisions / REF / review HTTP / 1.1401 12 - Apache-HttpClient / 4.4.1(Java / 1.8.0_20)



    IP - jenkins [26 / oct。/ 2016:14:30:08 +0200]POST / a / changes / REF / revision / REF / review HTTP / 1.1200 24 - Apache-HttpClient / 4.4.1 Java / 1.8.0_20)


    在第一个命令中,没有用户而是第二个有 jenkins 用户。此用户用于将Jenkins服务器连接到Gerrit服务器(ssh和REST API)。这是问题吗?






    到目前为止我尝试了多少



    重新配置Jenkins下的Gerrit触发器插件



    作为 @ Marcelo 提到,Sonar Gerrit插件使用Gerrit触发器。我在 Gerrit触发器设置之后重新配置了整个插件。 。



    我之前错过了为Label Verified添加Gerrit访问权限的步骤


    管理员>项目> ...>访问>编辑



    参考:refs / heads / *标签:已验证:-1,


    有关文章的详细说明无法在gerrit 2.7 中找到Label Verified权限。



    将已验证的标签从Jenkins发送到Gerrit 安装Gerrit的文档> 2.7。


    转到管理Jenkins并单击Gerrit触发器链接



    在您的服务器旁边的Gerrit服务器下,单击编辑按钮(看起来像
    像一个齿轮,其他图标可能会重叠)



    在Gerrit已报告值下点击底部的高级按钮



    在Gerrit Verified Commands下,从每个命令中删除--verified >






    软件版本




    • Jenkins 2.19.1 Git(2.5.3),Gerrit触发器(2.21.1),SonarQube(2.4.4),Sonnar Gerrit(1.0.6)插件。注意:Gerrit Trigger Rest API是可用的

    • SonarQube 5.5

    • Gerrit 2.12.2。


    解决方案怀疑您的Jenkins和Gerrit之间的REST API连接有问题。



    Sonar Gerrit插件使用Gerrit触发器插件在Gerrit中发布消息。 Gerrit Trigger插件可以使用两种不同的方法在Gerrit:SSH或REST API中发布消息。



    Build Failed ... FAILURE通过Gerrit触发器插件,它可以使用SSH执行。 Sonar Gerrit消息不能使用SSH执行,它们需要使用REST API完成,因此Gerrit触发器插件需要配置为使用REST API使Sonar Gerrit插件在Gerrit中发布。 / p>

    查看更多信息此处



    转到Jenkins>管理Jenkins> Gerrit触发器>编辑>高级



    并检查REST API是否已启用,以及是否按预期工作(使用测试REST连接按钮)


    I am trying to set up Sonar Gerrit - Jenkins Plugin on a Jenkins job.

    Context

    1. A Jenkins job is launched when a patch set is created to Gerrit
    2. Source are pulled with git, cppcheck analysis is launched and a sonar analysis is launched on preview mode.
    3. Post-Build action "Post SonarQube issues as Gerrit comments" is launched.

    Here are the Jenkins analysis logs for the third point.

    Getting Sonar Report from: [XX].sonar\sonar-report.json
    Report has loaded and contains 2950 issues
    Connected to Gerrit: server name: Gerrit. Change Number: 297, PatchSetNumber: 1
    Unable to post review: Request failed.
    Build step 'Post SonarQube issues as Gerrit comments' marked build as failure
    Finished: FAILURE
    

    A comment is added to Gerrit (meaning the communication works)

    Build Failed http:jenkins.com/job/project/118/ : FAILURE

    I am not able to understand where the configuration is not right. Do you know this issue ?

    On Gerrit httpd_log file I have following lines when I launched a new Jenkins job.

    IP - - [26/oct./2016:14:30:08 +0200] "POST /a/changes/REF/revisions/REF/review HTTP/1.1" 401 12 - "Apache-HttpClient/4.4.1 (Java/1.8.0_20)"

    IP - jenkins [26/oct./2016:14:30:08 +0200] "POST /a/changes/REF/revisions/REF/review HTTP/1.1" 200 24 - "Apache-HttpClient/4.4.1 (Java/1.8.0_20)"

    On first command, there is none user instead on the second one there is jenkins user. This user is used to connect Jenkins server to Gerrit server (both ssh and REST API). Is it this the issue ?


    What I tried so far

    Reconfigure Gerrit Trigger Plugin under Jenkins

    As @Marcelo mentioned, Sonar Gerrit plugins uses Gerrit trigger. I reconfigure the entire plugin following Gerrit trigger set up.

    I previously missed the step under adding Gerrit access rights for "Label Verified"

    Admin > Projects > ... > Access > Edit

    Reference: refs/heads/* Label : Verified: -1, +1 for Non-Interactive Users

    Detailed explanation on post Can't find 'Label Verified' permission in gerrit 2.7.

    Remove verified tag send from Jenkins to Gerrit As explained in install documentation for Gerrit > 2.7.

    Go to "Manage Jenkins" and click the "Gerrit Trigger" link

    Under "Gerrit Servers" next to your server(s) click the "Edit" button (looks like a gear, other icons may overlap it)

    Under "Gerrit Reporting Values" click the Advanced button at the bottom

    Under "Gerrit Verified Commands" remove the '--verified ' sections from each command


    Software Version

    • Jenkins 2.19.1 Git (2.5.3), Gerrit Trigger (2.21.1), SonarQube (2.4.4), Sonnar Gerrit (1.0.6) plugins. Note: Gerrit Trigger Rest API is functional
    • SonarQube 5.5
    • Gerrit 2.12.2. Events-Log plugin installed (default configuration)

    解决方案

    I suspect there's a issue with your REST API connection between Jenkins and Gerrit.

    The "Sonar Gerrit" plugin uses the "Gerrit Trigger" plugin to post messages in Gerrit. The "Gerrit Trigger" plugin can use two different methods to post messages in Gerrit: SSH or REST API.

    The "Build Failed ... FAILURE" message is posted directly by "Gerrit Trigger" plugin and it can be performed using SSH. The "Sonar Gerrit" messages CAN'T be performed using SSH, they need to be done using REST API so the "Gerrit Trigger" plugin needs to be configured to use REST API to enable "Sonar Gerrit" plugin to post in Gerrit.

    See more info here.

    Go to Jenkins > Manage Jenkins > Gerrit Trigger > Edit > Advanced

    And check if the REST API is enabled and if it's working as expected (using the "Test REST Connection" button)

    这篇关于无法设置“Sonar Gerrit” Jenkins插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆