@@ -162,10 +162,11 @@ reporter:
162162 reporter: Spotbugs
163163` ` `
164164
165- Then set your Bitbucket access token as environment variable :
165+ Then set your Bitbucket access token as environment variable and e.g. run with gradle (see below)
166166
167167` ` ` bash
168168export codeanalysisbb_bitbucket_token=yourToken
169+ ./gradlew exportToBitbucket
169170` ` `
170171
171172# # Artifacts served via JitPack
@@ -253,7 +254,7 @@ View the Pull Request. In the overview tab, there should be the report results.
253254
254255This example configures PMD and spotbugs in Maven and adds the `code-analysis-bitbucket-exporter` to export the results to Bitbucket insights.
255256
256- pom.xml
257+ ` pom.xml`
257258
258259` ` ` xml
259260<project xmlns="http://maven.apache.org/POM/4.0.0"
@@ -354,12 +355,6 @@ pom.xml
354355 </reporting>
355356
356357 <dependencies>
357- <dependency>
358- <groupId>junit</groupId>
359- <artifactId>junit</artifactId>
360- <version>4.11</version>
361- <scope>test</scope>
362- </dependency>
363358 <dependency>
364359 <groupId>org.slf4j</groupId>
365360 <artifactId>slf4j-simple</artifactId>
@@ -387,7 +382,6 @@ View the Pull Request. In the overview tab, there should be the report results.
387382
388383# # Integrate in Gradle with Sonarqube
389384
390-
391385This example configures Sonarqube in Gradle and adds the `code-analysis-bitbucket-exporter` to export the results to Bitbucket insights.
392386
393387` build.gradle`
@@ -414,7 +408,6 @@ sonarqube {
414408 property 'sonar.junit.reportPaths', 'build/test-results/test'
415409 property "sonar.sourceEncoding", "UTF-8"
416410 property "sonar.host.url", "https://sonarqube.example.com"
417- property "sonar.login", "123456789"
418411 property "sonar.verbose", "true"
419412 property "sonar.issuesReport.html.enable", "true"
420413 property "sonar.projectKey", "my-project-name-in-sonarqube"
@@ -438,9 +431,109 @@ task exportToBitbucket {
438431Be sure to add all other settings in `code-analysis-bb.yml`.
439432Be sure the current commit is the HEAD of a branch on Bitbucket and you have an open Pull Request for that branch.
440433
441- Run `./gradlew sonarqube` to run sonarqube analysis.
434+ Run `./gradlew sonarqube -Dsonar.login=<Sonar Login Token> ` to run sonarqube analysis.
442435When analysis is done, a file `build/sonar/report-task.txt` is created.
443- Now you can run `./gradlew exportToBitbucket`.
436+ Now you can run `./gradlew exportToBitbucket -Dcodeanalysisbb.reporter.sonarqube.login=<Sonar Login Token>`.
437+
438+ View the Pull Request. In the overview tab, there should be the report results.
439+
440+ Tested with Sonarqube 7.9.4
441+
442+
443+ # # Integrate in Maven with Sonarqube
444+
445+ This example configures Sonarqube in Maven and adds the `code-analysis-bitbucket-exporter` to export the results to Bitbucket insights.
446+
447+ ` pom.xml`
448+
449+ ` ` ` xml
450+ <project xmlns="http://maven.apache.org/POM/4.0.0"
451+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
452+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
453+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
454+ <modelVersion>4.0.0</modelVersion>
455+ <groupId>...</groupId>
456+ <artifactId>...</artifactId>
457+ <packaging>...</packaging>
458+ <version>...</version>
459+
460+ <properties>
461+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
462+ <maven.compiler.target>1.8</maven.compiler.target>
463+ <maven.compiler.source>1.8</maven.compiler.source>
464+ <sonar.host.url>https://sonarqube.example.com</sonar.host.url>
465+ <sonar.projectKey>my-project-name-in-sonarqube</sonar.projectKey>
466+ </properties>
467+
468+ <build>
469+ <plugins>
470+ <plugin>
471+ <groupId>org.codehaus.mojo</groupId>
472+ <artifactId>exec-maven-plugin</artifactId>
473+ <version>1.6.0</version>
474+ <executions>
475+ <execution>
476+ <id>exportToBitbucket</id>
477+ <goals>
478+ <goal>java</goal>
479+ </goals>
480+ <configuration>
481+ <includeProjectDependencies>false</includeProjectDependencies>
482+ <includePluginDependencies>true</includePluginDependencies>
483+ <mainClass>de.kekru.codeanalysisbb.CodeAnalysisBitbucketExporter</mainClass>
484+ <systemProperties>
485+ <systemProperty>
486+ <key>codeanalysisbb.workDir</key>
487+ <value>${project.basedir}</value>
488+ </systemProperty>
489+ <!-- set reportTaskFile location (can also be set in 'code-analysis-bb.yml') -->
490+ <systemProperty>
491+ <key>codeanalysisbb.reporter.sonarqube.reportTaskFile</key>
492+ <value>target/sonar/report-task.txt</value>
493+ </systemProperty>
494+ </systemProperties>
495+ </configuration>
496+ </execution>
497+ </executions>
498+ <dependencies>
499+ <dependency>
500+ <groupId>com.github.kekru</groupId>
501+ <artifactId>code-analysis-bitbucket-exporter</artifactId>
502+ <version>0.1.0</version>
503+ </dependency>
504+ <dependency>
505+ <groupId>com.google.guava</groupId>
506+ <artifactId>guava</artifactId>
507+ <version>25.1-jre</version>
508+ </dependency>
509+ </dependencies>
510+ </plugin>
511+ </plugins>
512+ </build>
513+
514+ <dependencies>
515+ <dependency>
516+ <groupId>org.slf4j</groupId>
517+ <artifactId>slf4j-simple</artifactId>
518+ <version>1.7.9</version>
519+ </dependency>
520+ </dependencies>
521+
522+ <pluginRepositories>
523+ <pluginRepository>
524+ <id>jitpack.io</id>
525+ <url>https://jitpack.io</url>
526+ </pluginRepository>
527+ </pluginRepositories>
528+ </project>
529+ ` ` `
530+
531+ Be sure to add all other settings in `code-analysis-bb.yml`.
532+ Be sure the current commit is the HEAD of a branch on Bitbucket and you have an open Pull Request for that branch.
533+
534+ Run `mvn package sonar:sonar -Dsonar.login=<Sonar Login Token>` to run sonarqube analysis.
535+ When analysis is done, a file `target/sonar/report-task.txt` is created.
536+ Now you can run `mvn exec:java@exportToBitbucket -Dcodeanalysisbb.reporter.sonarqube.login=<Sonar Login Token>`.
444537
445538View the Pull Request. In the overview tab, there should be the report results.
446539
0 commit comments