Prerequisite Install docker
Go to terminal on Mac and follow below steps
- docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube
- The above command downloads sonarqube image and uses h2 database.
- The sonarcube can be accessed at http://localhost:9000/about
- By default you can login as
adminwith passwordadmin, see authentication. - The moment you login you will given a screen to generate the token as below
Steps to integrate your local build to push reports to sonar.
- Add dependencies as - classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
Add the plugin as - apply plugin: 'org.sonarqube'
- Add properties in gradle.properties -
systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.login=Token generated in step 5,6
Command to push reports to sonar qube server
gradle sonarqube -Dsonar.host.url=http://sonar.mycompany.com -Dsonar.verbose=true ( we can skip -D params as they have been put in gradle.properties)
Integration of Jacoco and gradle
1. apply plugin: "jacoco"
2. Add below to build.gradle ,
jacocoTestReport {
group = "Reporting" reports { xml.enabled true csv.enabled false html.destination "${buildDir}/reports/coverage" } }
3. Run from command line ,
gradle test jacocoTestReport
References



Comments
Post a Comment