I am facing the below mentioned error in the Azure DevOps Pipeline. While checking the fix related to the error, its suggested to use org.sonarsource.scanner.maven:sonar-maven-plugin:sonar instead of sonar:sonar, and I have updated it in my Azure pipeline yaml file and after rerunning it as a new build the error remains same.
Azure Pipeline yaml template:
# Prepare Analysis Configuration task
- task: SonarQubePrepare@7
displayName: “Prepare SonarQube analysis”
inputs:
SonarQube: ${{ parameters.connectorName }}
scannerMode: “Other”
projectKey: ${{ parameters.projectKey }}
projectName: ${{ parameters.projectKey }}
# Maven Analysis task
- task: maven@4
displayName: “SonarQube Java scanner”
# condition: or(eq(variables[‘Build.SourceBranch’], ‘refs/heads/main’), eq(variables[‘Build.SourceBranch’], ‘refs/heads/master’))
inputs:
mavenPOMFile: “pom.xml”
mavenOptions: “-Xmx3072m -Dmaven.repo.local=${{ parameters.mavenCacheFolder }} ${{ parameters.mavenOptions }}”
goals: verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
options: >-
--batch-mode
-Dsonar.host.url=https://sonarqube.ourdomain.com
-Dsonar.token=${{ parameters.tokenProject }}
-Dsonar.projectKey=${{ parameters.projectKey }}
-Dsonar.projectName=${{ parameters.projectKey }}
-Dsonar.qualitygate.wait=true
-Dsonar.coverage.jacoco.xmlReportPaths=\\\*\\\*/jacoco.xml
-Dsonar.java.checkstyle.reportPaths=\\\*\\\*/checkstyle-result.xml
${{ parameters.mavenExtraArguments }}
publishJUnitResults: true
testResultsFiles: “**/surefire-reports/TEST-*.xml”
sonarQubeRunAnalysis: true
sqMavenPluginVersionChoice: “latest”
javaHomeOption: “JDKVersion”
jdkVersionOption: ${{ parameters.jdkVersion }}
mavenVersionOption: “Default”
mavenAuthenticateFeed: true
checkStyleRunAnalysis: true
effectivePomSkip: false
# codeCoverageToolOption: ‘JaCoCo’
isJacocoCoverageReportXML: true
Error:
[ERROR] No plugin found for prefix ‘sonar’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/vsts/.m2/repository), central (https://repo.maven.apache.org/maven2)] → [Help 1]
Guide me to the correct fix.