I am trying to set up Sonar Gerrit - Jenkins Plugin on a Jenkins job.
Context
- A Jenkins job is launched when a patch set is created to Gerrit
- Source are pulled with git, cppcheck analysis is launched and a sonar analysis is launched on preview mode.
- 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)