0
votes

How do I get the Maven plugin to work with SonarScanner?

I am running the following on RHEL 7.5:

yarn version: Hadoop 3.1.0

mvn --version: Apache Maven 3.5.3

SonarQube 7.1

node -v: v9.5.0

npm -v: 5.6.0

I go to this directory with a pom.xml file: /opt/sonarqube/web/META-INF/maven/org.sonarsource.sonarqube/sonar-web

I run this command:

sudo /usr/local/apache-maven/bin/mvn -X clean verify

I expect the build to work and be successful. But I get this error:

[INFO] Running 'yarn run build' in /opt/sonarqube/web/META-INF/maven/org.sonarsource.sonarqube/sonar-web [DEBUG] Executing command line [/opt/sonarqube/web/META-INF/maven/org.sonarsource.sonarqube/sonar-web/node/yarn/dist/bin/yarn, run, build] [INFO] yarn run v1.1.0 [ERROR] error Couldn't find a package.json file in "/opt/sonarqube/web/META-INF/maven/org.sonarsource.sonarqube/sonar-web" [INFO] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 12.336 s [INFO] Finished at: 2018-07-27T01:43:17Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:yarn (yarn run script) on project sonar-web: Failed to run task: 'yarn run build' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:yarn (yarn run script) on project sonar-web: Failed to run task at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)

I modified the settings.xml file for Maven. How do I get Maven to work with SonarQube?

1

1 Answers

1
votes

Analysis should be executed from project root and nowhere else. You appear to be executing it from ... within the directory of an expanded plugin file?

Also, the command to actually run analysis is:

 mvn sonar:sonar

Of course, that should be combined with a build, so it's generally used as:

mvn clean build sonar:sonar