Sunday, February 1, 2026

Fix Found | Error No plugin found for prefix 'sonar' in the current project | Jenkins throws error when Integrating with SonarQube when using Maven goal | Fix Explained

[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 is 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

     stage ('Code Quality scan')  {
       withSonarQubeEnv('Sonar') {
            sh """
              ${mvnHome}/bin/mvn -f MyWebApp/pom.xml \
             org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar \
              -Dsonar.organization=org_key \
              -Dsonar.projectKey=project_key \
              -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.

No comments:

Post a Comment