Sonar-Gerrit integration shows error in Jenkins - jenkins

There is a Jenkins freestyle job that is triggered by some Gerrit events.In response to triggers, it downloads the changes and runs a Sonarqube Analysis. The Sonarqube comments detailing the results are to be posted on Gerrit after the analysis is complete.This is the expected behaviour.
As of now, In Jenkins, the Sonarqube execution is success. But the build is failed mentioning the error " *ERROR: Build step failed with exception java.lang.IllegalArgumentException: Gerrit change number is empty*
Could anyone please help on this?
Reference:https://plugins.jenkins.io/sonar-gerrit/
Followed the same steps as mentioned in the above document.
Jenkins console output
Expected: The Sonarqube should post the comments to the respective Gerrit change,whether the Sonar-verified is +1/-1.

Related

What does information give the "continuous-integration/jenkins/pr-merge" status message?

I am using Jenkins 2.332.2 with Multibranch Pipeline. The job triggers on PullRequests from origin and from forks.
I do not understand the status message in GitHub for continuous-integration/jenkins/pr-merge. Independently of the status of the job, Failure or Success, I always get the message "
continuous-integration/jenkins/pr-merge Pending — This commit is scheduled to be built".
Jenkins job failed
Jenkins job succeded
Where I can find more information?
I could not find more information in the documentation of the Github Branch Source plugin: https://github.com/jenkinsci/github-branch-source-plugin
or
on the CloudBees website: https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-admin-guide/github-branch-source-plugin

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
Jenkins Maven job is launched when a patch set to Gerrit
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.
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.
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
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?
The error is:
Failed to execute command 'gerrit review 298816ea2b24645fd971a8c0833582cec1163dac -j'
Sonar-gerrit uses the gerrit-trigger plugin to vote in Gerrit. It seems there is something wrong with the gerrit-trigger configuration. I know you've checked the connection between gerrit-trigger and Gerrit but this is error is related to the "gerrit review" command.
Check the "gerrit review" command at:
Jenkins > Manage Jenkins > Gerrit Trigger > Edit > Advanced... > Gerrit Verified Commands
For example, it works to me with:
gerrit review <CHANGE>,<PATCHSET> --message 'Job finished <BUILDS_STATS>' --code-review <CODE_REVIEW>
After that, if the error persists, log in the Jenkins server and run the "gerrit review" command manually executing:
ssh -p 29418 jenkins#172.21.33.193 gerrit review
If you get the same error you can try to debug it adding "-vvv" to the command.

ERROR: Error during SonarQube Scanner execution

I have configured Jenkins Job for Sonar Quality Gate and Code Coverage. Below is the Jenkins job set Up. When I trigger the build I see below error. Most of my Jenkins jobs are failing because of this issue. Please help me out from this.
Jenkins Job setup
Error Logs
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Error at line 2 of coverage report C:\Location.xml
at org.sonar.plugins.coverage.generic.GenericCoverageSensor.loadReport(GenericCoverageSensor.java:130)
at org.sonar.plugins.coverage.generic.GenericCoverageSensor.analyseWithLogger(GenericCoverageSensor.java:95)
at org.sonar.plugins.coverage.generic.GenericCoverageSensor.analyse(GenericCoverageSensor.java:91)
at org.sonar.plugins.coverage.generic.ReportParser.parse(ReportParser.java:82)
at org.sonar.plugins.coverage.generic.GenericCoverageSensor.loadReport(GenericCoverageSensor.java:126)
... 31 more
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
The SonarQube Scanner did not complete successfully
21:44:09.12 Creating a summary markdown file...
21:44:09.122 Post-processing failed. Exit code: 1
The answer is there in the log:
org.sonar.plugins.dotnet.tests.ParseErrorException: Missing root element 'test-results' in C:\UC\ProductEligibility\BTS\results.xml at line 2
So the results.xml is not valid xml and causes a parse error and kills the analysis. So whatever creates that file, is causing the issue in the end.
Try to remove that parameter to verify if the analysis runs correctly now.

Show SonarQube result link on Jenkins Job page

I use jenkins and sonar to analyze some projects. The sonar analyzing triggered over the groovy pipeline script with the following code:
stage('SonarQube analysis')
def scannerHome = tool 'SonarQube_Scanner_Prod';
sh "${scannerHome}/bin/sonar-scanner -e -Dsonar.host.url=... -Dsonar.projectKey=... -Dsonar.projectName=... -Dsonar.sources=... -Dsonar.projectVersion=..."
This work fine. Now I want a link on the jenkins job page. To come to the sonar results on the server. After the sonar analysis run, the link is on the console. Can i add this link to the status page? Or add a link to the left menu? Thank you for help.
As far I know Once the job is complete, the plugin will detect that a SonarQube analysis was made during the build and display a badge and a widget on the job page with a link to the SonarQube dashboard as well as quality gate status.
Please refer this and verify your configurations.

Jenkins - Integrating JIRA with Jenkins, for creating ticket automatically when build fails, in Jenkins

I am using Jenkins to run jobs and want to create/update tickets in JIRA, whenever build fails. I have downloaded JIRA plugin, Jira Issue Updater, JiraTestResultReporter plugins and configured URL and credentials, under Manage Jenkins/Configure System.
In the job am running, under Post-build Actions, I added 'Create Jira Issue' with project key, assignee name etc and 'Jira Test Result Reporter' with all required credentials.
I get the following error in the console:
ERROR: Publisher 'Jira Test Result Reporter' aborted due to exception:
java.lang.NoSuchMethodError: hudson.model.AbstractBuild.getTestResultAction()Lhudson/tasks/test/AbstractTestResultAction;
at JiraTestResultReporter.JiraReporter.perform(JiraReporter.java:105)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
at hudson.model.Run.execute(Run.java:1769)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:374)
Finished: FAILURE
Any idea whats going wrong? Is it not able to find the project? I have access to create ticket in the project specified, in jira.
It is generally possible to create tickets in JIRA programmatically, for example via their REST API.
Regarding your error, this behavior was introduced when the method signature of getTestResultAction() changed to return an Action instead of an AbstractTestResultAction.
The effect on the JiraTestResultReporter plugin is a known issue and is tracked at JENKINS-25140.
The error was fixed in the source of the plugin a while ago, but is still pending a release.
Solution:
As a workaround, Daniel Beck suggests to build and install a snapshot of the current JiraTestResultReporter plugin which seems to solve this particular error (see comments to the Jenkins ticket mentioned above).

Resources