Maven
Configuration
Configure the Maven project to use the Sonar™Scanner as shown in the SonarQube™ Wiki.
See the official Maven example for inspiration
Ensure the
pom.xml
of your project contains thesonar-maven-plugin
as dependency<build> <pluginManagement> <plugins> <plugin> <groupId>org.sonarsource.scanner.maven</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>3.7.0.1746</version> </plugin> </plugins> </pluginManagement> </build>
[optional: code coverage] ensure your
pom.xml
integrates the Jacoco plugin, see Java test coverage for more details.
[optional: code coverage] Add a Maven task to your Bamboo job:
Run the tests and generate code coverage reports:
clean org.jacoco:jacoco-maven-plugin:prepare-agent verify
Add a Sonar™Scanner for Maven task to your Bamboo job:
Tips & Troubleshooting
If you use Sonar™Scanner Maven task on a remote agent, set the Maven capability by
adding a Maven 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.mvn3.Maven3=path/to/your/maven3/home
The 'Maven3' 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.