Unable to run Maven Build from Azure Pipeline

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

Trying to scan Java code using Maven Build from Azure pipeline.

Here are some error logs

  1. [INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 01:04 min

[INFO] Finished at: 2021-06-17T16:04:07+05:30

[INFO] ------------------------------------------------------------------------

[ERROR] Could not find goal ‘’ in plugin org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155 among available goals help, sonar → [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException

The process ‘D:\apache-maven-3.8.1-bin\apache-maven-3.8.1\bin\mvn.cmd’ failed with exit code 1

Could not retrieve code analysis results - Maven run failed.

##[error]Build failed.

Async Command Start: Publish test results

Async Command End: Publish test results

##[error]Forbidden

Finishing: Maven pom.xml

can anyone help on this?

Hello,
what exactly is your setup in Azure? What maven goal are you running? Do you have a sonar-maven-plugin version locked in your pom file? Can you just run mvn sonar:sonar?

Hi Duarte Meneses,

Thankyou for your response. This is the first time we are using sonarqube, earlier deployment template (pom.xml) doesnt have any sonar dependency.

Steps what we followed are

Step 1. we created a dedicated parallel pipeline for Sonarqube

#sonarqube pipeline for Pre PR static code analysis

trigger:

  • master

pool: *******************

steps:

  • task: SonarQubePrepare@4
    inputs:
    SonarQube:‘
    scannerMode:‘CLI’
    configMode:‘manual’
    cliProjectKey:
    *****
    cliProjectName:******************
    cliSource:’’
    extraProperties:|
    sonar.tfvc.collectionuri = https://dev.azure.com/********************
    sonar.tfvc.pat.secured=*************************************************
  • task:SonarQubeAnalyze@4

Step 2:

We got warning error to use maven in built sonar scanner

so we added a maven build and checkbox the sonar analytics tab in it and added a sonar preparation before that.

Hi @venkatSQ

Have you checked the SonarQube service connection ? Is the token correct there ?

Thank you.

HI @mickaelcaro,

Yes we checked the service connection, token is correct there. me and @venkatSQ is facing the same issue.

Regards,
Amit

Can you share please the full log of the execution, preferably with debug mode enabled please ?

Let me know if you want to share it privately.

Thanks.