I am unable to do code analysis from jenkins,I am getting 403 error.The Execute Analysis permission is provided for all the sonar users,sonar administrator and project creators,but still iam getting 403.
In jenkins job i have used goal sonar:sonar
Am i missing anything in the configuration?
Error :
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli) on project core: Unable to load component class org.sonar.api.config.Settings: Unable to load component class org.sonar.scanner.repository.ProjectRepositories: You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator. -> [Help 1]
Unless you've granted permissions to Anyone to perform analysis, then you will continue to have this failure because you're not providing credentials. Instead:
mvn sonar:sonar -Dsonar.login=analysis_token_here
Where the value of the login parameter is a User Token
Related
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project maven-project: Failed to upload report: You're not authorized to run analysis. Please contact the project administrator. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project maven-project: Failed to upload report: You're not authorized to run analysis. Please contact the project administrator.
is anyone faced this issue.please help to resolve this issue
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.
I am running Execute SonarQube Scanner on Jenkins, but the job always fails.
The job log shows:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:
sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project
helpRequestMgmtUI: Not authorized. Please check the properties
sonar.login and sonar.password. -> [Help 1]
In job configuration, I added the following into Analysis properties:
sonar.projectKey=org.sonarqube:javascript-lcov-sq-scanner
sonar.projectName=My project
sonar.projectVersion=1.0
sonar.language=js
sonar.sources=webapp
sonar.sourceEncoding=UTF-8
sonar.javascript.coveragePlugin=jacoco
sonar.login=admin
sonar.password=admin
In the last two lines I have already added user name and password but it does not work for executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603
However, the SonarQube dashboard is created successfully.
How do I avoid this authorization exception, when analysing my project?
Using pipeline code,
withSonarQubeEnv {
dir ('/mydirectory/') {
sh "'${mvnHome}/bin/mvn' org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar -Dsonar.projectKey=somemykey -Dsonar.projectName=somemyname"
}
Which outputs:
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project myproject: Not authorized. Please check the properties sonar.login and sonar.password.
If that is expected behavior then how to avoid pasting login and password? If not what is the root cause of it? Is it a problem with Sonar server configuration?
At the global level you should configure your server instance to include an analysis token from a user with Global Execute Analysis permissions. Either that, or include a project-specific user token at the analysis level.
The error message asking for login/password is a bit outmoded. You can still use login/password, but analysis token is the recommended way.
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.