Sonar plugin not working for projects that use ANT as a build script


I have just installed the Sonar Jenkins plugin. I went into my configured job (a free style job) that produces a WAR file artifact through an ANT build and did as follows:

  • How to manage a common ant build script across multiple project build jobs on jenkins?
  • Run batch scripts on a remote server (windows) from jenkins
  • Saving Git SHA1 when building with Hudson similar to the CVS_BRANCH tag for CVS
  • Checkout svn using gradle
  • How to tell ANT-exec, the location of git executable
  • The svn client 'svnkit' is not available
    1. Check the Sonar checkbox. (No problems here)

    2. Configure the install dir of sonar (No problems here)

    3. Checked the checkbox that states: “Check if this project is NOT built with maven 2″ (I am confused here)

      I have checked that box because I am not using maven for build, I am using ANT but it still asked me for required properties that resemble a lot MVN such as: Organization id, project id, project name, project version, source directories… etc..

      So I have filled those as well. When I click the play button “Build Now” the build seems to be running fine as it always had prior to sonar installation but it fails at the very end because its trying to execute MAVEN.

    See as follows:

    $ mvn -f /root/.jenkins/jobs/HRDA/workspace/pom.xml -e -B sonar:sonar
    FATAL: command execution failed Cannot run program “mvn” (in directory “/root/.jenkins/jobs/HRDA/workspace”): error=2, No such file or directory


    1. Why is Sonar trying to execute Maven if I have checked the box that said check this box if you do NOT use Maven 2?

    2. Can I make use of this Sonar plugin if my apps are built with ANT, GANT, GRADLE?

    3. Do I have to reconvert my apps to use MVN builds?

    – Dario

  • configure Jenkins “Global Tool Configuration” using CLI / groovy
  • Jenkins pipeline template
  • Jenkins + Git Publisher - How to push back to {GIT_BRANCH}?
  • How to add a href links in <system-out> or <failure> tags in Jenkins/JUNIT xml
  • Protractor is not recognized as an internal or external command, operable program or batch file
  • timeout from soap request using jax-ws
  • One Solution collect form web for “Sonar plugin not working for projects that use ANT as a build script”

    Like Oers suggested on my question comments if you are using ANT as a build script in your CI server (Jenkins in my case) you will have to use the SONAR-ANT-TASK to generate Sonar reports, do as follows:

    1. Download MySQL or any other Sonar supported RDBMS such as Postgres, Oracle, etc..’
    2. Download and Install sonar server.
    3. go to (sonar installation folder)/extras/database/mysql and run the create_database.sql script.
    4. I had to run an extra sql statement in my case using mysql, you can see here Unable to access Sonar MySQL database Caused by: java.sql.SQLException: Access denied for user 'sonar'@'glassfishdev.ccs.local' (using password: YES)
    5. Start Sonar by typing ./ start
    6. Add the sonar ant task to your build script. You can follow this template
    7. DO NOT check the sonar check box in your Configure screen if you have the Hudson Sonar plugin for installed, as this plugin only works with Maven projects.
    8. Click the “Build Now” button. If everything above has been done correctly you should be able to see the reports at http://ipaddressofmachinesonarisinstalled:9000/

    Hope this helps,

    Git Baby is a git and github fan, let's start git clone.