Configuration
-
Configure the Gradle project to use the Sonar™Scanner as described in the SonarQube™ Wiki.
-
See the official Sonar™Scanner Gradle example projects for inspiration
-
-
Add a Sonar™ Scanner task to your Bamboo job:
Project key in Gradle
-
Specify a project key in your
build.gradlefile in order to have a fixed project key which is necessary for SonarQube™-based code reviews.XMLsonarqube { properties { property 'sonar.projectKey', 'com.company.team:project' } } -
If you are using SonarQube™ Community Edition, you need to specify the Project key again on the Bamboo Task:
-
Enable
Override SonarQube properties from build -
Set the project key:
-
To get test coverage in SonarQube™, please follow the instructions in the SonarQube™ Wiki.
Tips & Troubleshooting
If you use Sonar™ Gradle task on a remote agent, set the Gradle capability by
-
adding a Gradle capability to your remote agent in the Bamboo UI
-
or add the following key/value pair to your
bamboo-agent-home/bin/bamboo-capabilities.propertiesfile, see Bamboo docs for more details:system.builder.gradle.Gradle=path/to/your/gradle/home
The 'Gradle' part is the executable label.
SonarQube™ scanners need access to the full git repository. If you encounter issues, e.g. in a containerized build, ensure that you
-
uncheck "Use shallow clones" option (Fetches the shallowest commit history possible. Do not use if your build depends on full repository history)
-
check "Fetch whole repository" option (Fetches whole repository instead of only one branch)