There are various ways to do this. Using bamboo is a very nice way of running ant scripts like this, but you can also run the jobs manually or using a cron job.
You should analyse and modify the antbuild.xml file to your needs. But by default the jobs you can run are:
ant -f ../antbuild.xml deletesrc
deletes all the LOCAL source code (so that you will detect any source code changes)
ant -f ../antbuild.xml download
downloads all the source code from the Salesforce server
ant -f ../antbuild.xml commit
commits to your scm using the ‘last modified date’ meta data from Salesforce.
ant -f ../antbuild.xml commitall
commits any uncommited code (because of missing metadata, etc) using a standard user and message
ant -f ../antbuild.xml sonar
run the actual SonarQube analysis job.
ant -f ../antbuild.xml analyse
runs a combination of the above. By default we specify: ‘deletesrc, download, sonar’