Gradle

Configuration

  1. Configure the Gradle project to use the Sonar™Scanner as described in the SonarQube™ Wiki.

    1. See the official Sonar™Scanner Gradle example projects for inspiration

  2. Add a Sonar™ Scanner task to your Bamboo job:

    Sonar Gradle task confiugration

Project key in Gradle

  • Specify a project key in your build.gradle file in order to have a fixed project key which is necessary for SonarQube™-based code reviews.

    sonarqube { properties { property 'sonar.projectKey', 'com.company.team:project' } }
  • If you are using Sonar Community Edition, you need to specify the Sonar Project key again on the Bamboo Task:

    • Enable ‘Override Sonar properties from build’

    • Set the project key:

      image-20240111-054932.png

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.properties file, see Bamboo docs for more details:

    system.builder.gradle.Gradle=path/to/your/gradle/home

The 'Gradle' part is the executable label.











SONAR™, SONARQUBE™ and SONARCLOUD™ are independent and trademarked products and services of SonarSource SA: see sonarsource.com, sonarqube.org, sonarcloud.io.