[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 (/var/lib/jenkins/.m2/repository), central (https://repo.maven.apache.org/maven2)]
[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] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
Fix:In Jenkins: don’t use
sonar:sonar in the
Maven targets field. Instead, call the Sonar goal with the fully-qualified plugin.
problem command --> mvn clean install sonar:sonar
Fixed Code is --> mvn clean install org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar
Jenkins Pipeline Code
node {
def mvnHome = tool 'Maven3'
stage ("Checkout") {
git branch: 'main',
credentialsId: 'id',
url: 'https://github.com/akannan1087/myNov2025WeekendRepo'
}
stage ('Build') {
sh "${mvnHome}/bin/mvn clean install -f MyWebApp/pom.xml"
}
stage ('Code Quality scan') {
withSonarQubeEnv('SonarCloud') {
sh """
${mvnHome}/bin/mvn -f MyWebApp/pom.xml \
org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar \
-Dsonar.organization=akannan1087 \
-Dsonar.projectKey=com.dept.app:MyWebApp \
-Dsonar.projectName=MyWebApp
"""
}
}
}
Why this happens
sonar:sonar
relies on Maven “plugin prefix resolution”, which is not always reliable
in Jenkins jobs, especially with older Maven/Jenkins integration. Fully
qualifying the plugin is the standard CI fix.
def mvnHome = tool 'Maven3'
stage ("Checkout") {
git branch: 'main',
credentialsId: 'id',
url: 'https://github.com/akannan1087/myNov2025WeekendRepo'
}
stage ('Build') {
sh "${mvnHome}/bin/mvn clean install -f MyWebApp/pom.xml"
}
stage ('Code Quality scan') {
withSonarQubeEnv('SonarCloud') {
sh """
${mvnHome}/bin/mvn -f MyWebApp/pom.xml \
org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar \
-Dsonar.organization=akannan1087 \
-Dsonar.projectKey=com.dept.app:MyWebApp \
-Dsonar.projectName=MyWebApp
"""
}
}
}
























