How to Use SonarCloud
This guide helps you to integrate SonarCloud in your Travis build.
Steps
- First, you should be member of Apache Orgnization in Github.
- Login to sonarcloud.io with your Github credentials.
- Create an JIRA ticket in Infrastructure asking to create a project at SonarCloud, here is an example. You should provde Github repo url, project-key (the id of your project in SonarCloud), Github id for the Admin of this project, generally speaking that’s yours.
- Wait for the INFRA team creating the project, after that you will see it at SonarCloud.
- Follow the SonarCloud instructions modify project’s
.travis.yml
About Shallow Clone
Travis use shallow clone by default, and SonarCloud needs commit information, so you need to disable shallow clone:
git:
depth: false
About PR
Travis doesn’t support SonarCloud in PR build, you should modify your build script like this:
echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "Not a pull request build, running build with sonar"
mvn ... sonar:sonar -Dsonar.projectKey=<project-key>
else
echo "Pull request build or local build"
mvn ...
fi;