Search code examples
jenkinssonarqubegerritsonar-gerrit

Setting up Sonar-Gerrit plugin : Failed to execute command 'gerrit review ' on UserAtHost


I'm trying to set up the Sonar-Gerrit plugin on a Jenkin job.

Set up

  1. Jenkins Maven job is launched when a patch set to Gerrit
  2. I see the error in the Jenkins output.

Here is the Jenkins console error output :

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar ( default-cli) on project parent: Failed to execute project builder: fr.techad.sonar.GerritProjectBuilder: Failed to execute command 'gerrit review 298816ea2b24645fd971a8c0833582cec1163dac -j' on UserAtHost@55a9f72f [user=jenkins, host=172.21.33.193, port=29418]: reject HostKey: 172.21.33.193 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

What I have tried so far

Looking the [Help 1].It says

this exception is not generated by the Maven core itself but by a plugin.

  1. I tried to log in the Jenkins server and run "mvn sonar:sonar" in the directory(/usr/share/tomcat/.jenkins/workspace/sonar-maven).It runned successfully and I could see the results on the Sonar Dashboard.
  2. Reconfigure Gerrit Trigger plugin. Then I checked the connection in the Gerrit Trigger,and it sad successful.

Did anyone have this same error? how can I try to fix it?

Software Version

  • Jenkins 2.101 , Sonar-Gerrit plugin (2.3) ,Gerrit Trigger (2.21.2)
  • Gerrit 2.14.6
  • Sonarqube 6.7

Solution

  • your exception says:

    [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin
    

    It's your maven plugin for sonar is failing the job, not the sonar-gerrit plugin.

    Failed to execute command 'gerrit review 298816ea2b24645fd971a8c0833582cec1163dac -j'
    

    I don't know what does sonarqube command "gerrit review -j" and it looks like that this sonar-maven-plugin doesn't know it, either.

    You could try looking into this question - it may help you to configure sonarqube for your project: Why Maven command MVN sonar:sonar works without any plugin configuration in my POM.xml?