Failed to execute goal. Should I modify the pom?

Hi,
I have the same error, but with a different use case.

I have the error in the title of this topic during the following command:

mvn sonar:sonar -Dsonar.login=$LOGIN -Dsonar.host.url=$HOST -Dsonar.projectKey=$Project -Dsonar.organization=$Organization

I configure the Organization and the Project and I noticed that it suggest to modify the pom.xml adding the following lines:

<properties>
  <sonar.organization>MYPROJECT</sonar.organization>
  <sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

Should I modify the pom.xml? Because the mvn command has both host and organization as parameters

Thank you

Hello @Igor_Ferretti ,

In general, we recommend to store the host url, project key, and organization in the properties section of your pom.xml.

I am not sure though that this is going to fix the problem. Could you provide a more detailed error message?

Hi @Martin_Bednorz,
thank you for you answer.

In my usecase I not able to change anything on the code, also the pom.xml, but if it is necessary I will ask to the dev team to do it. But in this case I think that adding those configuration is not the problem.

I will give you additional information about my issue, keep in mind that now I also try with the following command suggested by SonarCloud for a Maven Project:

mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.login=$LOGIN -Dsonar.host.url=$HOST -Dsonar.projectKey=$Project -Dsonar.organization=$Organization

This is the error message:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar (default-cli) on project ***.main: Not inside a Git work tree: /codebuild/output/src289110846/src -> [Help 1] 

More in details this is the result of the command that was run:

[INFO] Reactor Build Order:
[INFO] Project AEM Website [pom]
[INFO] Project AEM Website - Webservices [bundle]
[INFO] Project AEM Website - Core [bundle]
[INFO] Project AEM Website - UI Frontend [pom]
[INFO] Project AEM Website - UI apps [content-package] 

[INFO] skip non existing resourceDirectory /codebuild/output/src289110846/src/ws/src/main/resources 

[INFO] Project AEM Website ................................ FAILURE [ 25.200 s]
[INFO] Project AEM Website - Webservices .................. SUCCESS [  3.539 s]
[INFO] Project AEM Website - Core ......................... SUCCESS [ 22.722 s]
[INFO] Project AEM Website - UI Frontend .................. SUCCESS [ 49.366 s]
[INFO] Project AEM Website - UI apps ...................... SUCCESS [ 27.663 s]

If i run:

mvn test

the result is the following:

[INFO] Project AEM Website ................................ SUCCESS [ 6.798 s]
[INFO] Project AEM Website - Core ......................... SUCCESS [01:24 min]
[INFO] Project AEM Website - UI Frontend .................. SUCCESS [01:04 min]
[INFO] Project AEM Website - UI apps ...................... SUCCESS [01:29 min] 

So I’m not expert in pom files, but could be something the pom files? It seems that because of missing source in “/src/ws/src/main/resources” and due to “skip” action it fails.

If you need additional information and logs please ask.

Thank you in advance

Hello @Igor_Ferretti,

This probably has something to do with the way AWS CodeBuild checks out your project sources. Most CIs use a git clone command, but on AWS CodeBuild the project sources are downloaded as a zip file. This means that there is no .git folder present in the CodeBuild environment.

This is what the Not inside a Git work tree exception is saying.

Could you share the settings that are set when you navigate to your project on SonarCloud and click on Administration > General Settings > SCM?

Hi @TomVanBraband ,
thank you for you answer, the settings for SCM are the default one and you can see it in the screenshot attached.

Is there anything that I can change there?
Moreover, why the other modules works or for example if I run “mvn test” works despite I always use AWS CodeBuild?

Thank you a lot,
Regards

Can you try disabling the SCM sensor on that page and re-run a CodeBuild task for that project?

mvn test only executes the tests. Tests don’t rely on having git metadata available. It is not maven that is failing, but the scanner which is written by us.

The logic in the scanner that fails is only executed for the top level module, so that’s why only that module fails.

Hi @TomVanBraband,
thank you for your answer! It works fine now, that was the problem!

Regards,

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.