Issues in sonar analysis through Maven of php project - sonarqube

I am trying to do sonar analysis through maven of a php project.
I have gone followed all the instruction mentioned on http://docs.codehaus.org/display/SONAR/PHP+Plugin, have done all the necessary set up and changes mentioned.
I am getting following error messages after execution of the command mvn sonar:sonar from project directory.
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (d
efault-cli) on project espritKM: Can not execute Sonar: PHPMD execution failed w
ith returned code '255'. Please check the documentation of PHPMD to know more ab
out this failure. -> [Help 1]

In such case, you should run the analysis in Debug mode (i.e. with "-X") in order to find which exact PHPMD command is launched and then run it manually in a shell to see what's happening.

Related

Maven - jenkins pipeline not using pom

I have a problem running a maven deploy through Jenkins. When run locally, the correct URL is contacted, but via Jenkins(in the middle of a pipeline), it does not. It also states that it is using a different plugin to do so. How do I get Jenkins to contact MY_URL like my command line does?
(I've cleaned up the output a bit)
Running the following through the command line gives me:
mvn clean deploy -DaltDeploymentRepository=nexus::default::https://MY_URL/ -DskipTests -P nexus -X -s ./settings.xml
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project MY_PROJECT: Failed to deploy artifacts: Could not transfer artifact from/to nexus (https://MY_URL): Failed to transfer file 20200217.092316-15.jar with status code 401 -> [Help 1]
This is what I want (I'm waiting on credentials - but it is hitting the correct URL)
Running via Jenkins gives me:
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.5.1:deploy (default-deploy) on project : Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
I have done a "diff" on the pom files in use by jenkins and locally and they are identical; likewise with the settings.xml I suspect this is a plugin problem but do not know where to go with it.
Items I have tried:
mvn clean beforehand
reinstalling mvn
echoing the settings.xml and pom.xml into the jenkins output
Specifying altDeploymentRepository in the settings.xml and/or
commandline
Specifying altDeploymentRepository using the -Dproperties= flag
Combinations of altDeploymentRepository, altDeploymentDirectory,
altSnapshotDeploymentRepository
Endless research
Hopeful reruns
Banging head on desk
Your Jenkins runs the org.sonatype.plugins:nexus-staging-maven-plugin:1.5.1:deploy goal.
It is either specified in the POM or given on command line. So first of all, check whether the nexus-staging-maven-plugin is configured in your POM or in one of the parent POMs. If so, check if it run conditionally or is part of a profile.
Secondly, look at the command line call in Jenkins and see if it is exactly the same as the one you ran locally.
The third possibility is that you run a Jenkins plugin from Sonatype that implicitly tries to deploy artifacts. So watch out for Sonatype specific Jenkins plugins.
One of the three strategies should lead to the source of the problem.

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

Maven pom configuration to see the errors on netbeans console

I have some problem when I try to run maven on netbeans the netbeans-console write:
Failed to execute goal XXXXXX on project MavenEnterpriseApp-ear: XXX failed (result=1) -> [Help 1]
My question is, existe some configuration on the pom that I can use to see what happend with the plugin without run mvn on console? and if not how can I do that?
Thanks...
You can invoke maven with the -e option to receive a more detailed error message including a stacktrace. This option can be set as the default in NetBeans by selecting
Tools -> Options -> Miscellaneous -> Maven
And adding -e to "Global Execution Options".

Resources