jenkins - maven - sonar 3.7 - maven

we had
Jenkins 1.513 - Maven 3.0.5 - Sonar 3.5
combo setup for our projects.
After upgrading Sonar to version 3.7 i get the following error, on all projects:
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.1:sonar (default-cli) on project RC: Can not execute SonarQube analysis: Unable to execute Sonar: Task null does not exist -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.1:sonar (default-cli) on project RC: Can not execute SonarQube analysis
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute SonarQube analysis
at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:109)
at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:67)
at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:109)
...
Caused by: org.sonar.api.utils.SonarException: Task null does not exist
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:78)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:88)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:73)
Now, i get that it's a NullPointerException, but i couldn't find what/where to do to make things works again.
Any ideas would be appreciated :)
Thank you,
Marian

Ok, so obviously the error was human:
I should've understood, not just read this particular line:
If for any reason, has to change (moving the SonarQube distribution into another directory, generating the WAR and deploying it on different machines, etc.), set the SONAR_HOME environment variable to the new path to .
from the
Deploying SonarQube on Tomcat documentation.
Since I was doing an upgrade, i didn't want to remove the Sonar's old installation just yet, so i installed the new version in sonar-3.7 without updating the $SONAR_HOME variable which pointed to the /sonar folder (doh)
I found out after my initial post that the above mentioned error occured only when running SonarQube as webapp in Tomcat. In standalone mode, it was running fine.
Maybe this is one of the reasons why it is stated :
Note that the support of Tomcat will be dropped in version 4.1 of SonarQube.
Thus, it is highly recommended to stick with the standalone mode and not deploy SonarQube on Tomcat.
on the mentioned page.
It's easier to make an application more stupid proof just saying "don't do that" rather than fixing your own NullPointerExceptions. The only risk with this approach is that the stupid must understand what he's reading.

Related

maven-deploy-plugin goal failed to achieved - working fine in window agent, build failed in Unix agent (Azure Pipeline)

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project **xxxxxxxxxx**: Execution default-deploy of goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy: java.lang.NoSuchMethodError: org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.getBufferCapacityForTransfer(J)I
Same pom.xml was used in two agents but error occurs in unix agent. Anyone knows what is the possible reason for the error?
The version of Maven on the Unix system is probably old and not compatible with the Mule Maven Plugin. Try upgrading to a newer version that is compatible.
The issue is documented at this KB article: https://help.mulesoft.com/s/article/An-API-incompatibility-was-encountered-while-executing-org-apache-maven-plugins-maven-deploy-plugin-while-deploying-an-asset-to-Exchange-using-Exchange-Maven-Facade-v3

We have a case where there are multiple projects configured in sonar. All the project have different modules with same names?

We have a case where there are multiple projects configured in sonar. All the project have different modules with same names.
With this, as and when we execute sonar for one of the project, the execution is getting terminated with below error.
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project XXX: Module "XXXX" is already part of project "YYYY" -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project XXXX: Module "YYYY" is already part of project "YYYY"
It seems that because the module name is same , Sonar is terminating the execution. Note that we are using sonar version 4.5.5 and facing this issue. While earlier we were using sonar version 4.1.1 and with that version the execution was successful (probably sonar was overriding earlier report with the newer one in case of conflicting module name).
Please suggest possible solution for this? Thanks,
Complete error log is available here
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/sonarqube/-L7cby77-28/6L6zPlb6AAAJ
I think you need to rename you modules like if your project is abc.
Please change your modules like abc_xxx etc...it may work for you
Have you tried using the project name property?
In a pom.xml file:
<sonar.projectName>Some project name here</sonar.projectName>

local sonar analysis using a remote sonar server

I am doing a sonar analysis from my machine using a sonar instance on a remote server.
Local machine: Window7, apache-maven-3.2.5
Remote sonarcube server: sonarcube Version 3.7.3
I am using below command from command prompt:
mvn sonar:sonar -Dsonar.jdbc.url=<jdbcurl> -Dsonar.host.url=<sonarserver url>
I have defined a sonar profile for running the same
Whe I run the said mvn command, then I am getting below error:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project builder-allmodules: Can not execute SonarQube analysis: Can not execute Findbugs: java.lang.RuntimeException: edu.umd.cs.findbugs.NoClassesFoundToAnalyzeException: No classes found to analyze in mymavenproject\target\classes *xyz.jar *F:\m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar *abc.jar *lmn.jar aaa.jarbbb.jar *ggg.jar
mymavenproject\target\classes: doesn't have any classes, instead, there is bundled jar at mymavenproject\target\ which contains all the classes
Also, another issue is that it is trying to analyze all the dependent jars also which should not be the case as I need sonar analysis for my project only
Can you let me know what I might be missing?
Because you've included FindBugs rules in your analysis profile, you're required to provide unbundled classes to the analysis.

Logging error when executing Maven SonarQube plugin

I've been facing an issue with Maven SonarQube plugin (v2.6) when Maven version is recent (strictly larger than 3.1).
Here is what I run:
mvn clean verify -Psonar
mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar -Psonar
The first invocation makes sure sources are compiled and JaCoCo agent is prepared.
The interesting part comes, when the second command is run:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project merlin-schema: Error setting Log implementation. Cause: java.lang.reflect.InvocationTargetException: org/slf4j/Marker -> [Help 1]
Any fix to be published?
Replacing default Maven logging implementation is currently not supported. Ticket created: http://jira.sonarsource.com/browse/MSONAR-122

First time SONAR setup with Maven, getting a error on RulePriority, analysis fails

I am trying to setup SONAR on a server. I have Maven 3.0.3 and using Sonar 3.1.1 with a Java project.
Part way through the mvn sonar:sonar, I am getting the following error:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project XXXXXXX-common: Can not execute Sonar: No enum const class org.sonar.api.rules.RulePriority.3 -> [Help 1]
I have setup Sonar before and never saw this, it has always been unzip and go. But on this particular server I keep getting this error.
I tried creating a blank rule set, but the error still pops up.
Any thoughts?
I think you are facing the same problem described here
http://sonar.15.n6.nabble.com/Xpath-rules-gt-Failed-startup-of-context-td3183230.html
You might find it useful

Resources