Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:

I am getting this error when I run my mvn projects. I think it might be due to my script being
mvn package sonar

Does it have to be mvn clean verify or mvn clean install?


you didn’t post the whole stacktrace and the details (Sonarqube version, Java version, Maven version), but i guess the problem is the wrong syntax.
It has to be mvn ... sonar:sonar instead of mvn ... sonar

The only difference between using verify or install is the list of executed maven build phases.
i.e. the default lifecycle consists of

  • validate
  • compile
  • test
  • package
  • verify
  • install
  • deploy

That means if you use mvn clean install it will execute validate, compile, test, package and verify phases.
Note that the Sonarqube analysis has to run with Java 11 or - if using Sonarqube 9.9 - Java 11 or 17.


But from the documentation examples from here
It uses mvn ... sonar:sonar
mvn clean verify sonar:sonar -Dsonar.login=myAuthenticationToken

I am using SonarQube 9.9 Enterprise, and Java 11, with maven plugin

ok, your script uses sonar:sonar but you wrote

You should post the whole stacktrace - with the sensitive parts redacted - to see the error in context, as ‘failed to execute goal …’ is very generic.
Use mvn -X … to increase the loglevel.