Re-introduced sonarqube integration
@@ -29,6 +29,32 @@ jobs:
paths:
- ~/.m2
+ sonar-pr:
+ working_directory: ~/fabric8io/dmp-sonar-pr
+ docker:
+ - image: circleci/openjdk:8-node-browsers
+ steps:
+ - checkout
+ - restore_cache:
+ key: dmp-sonar-pr-{{ checksum "pom.xml" }}
+ - run: |
+ if [ -n "${CIRCLE_PR_NUMBER" ]; then
+ mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar \
+ -Dsonar.analysis.mode=preview \
+ -Dsonar.github.pullRequest=${CIRCLE_PR_NUMBER} \
+ -Dsonar.github.repository=fabric8io/docker-maven-plugin \
+ -Dsonar.github.oauth=${GITHUB_COMMENT_TOKEN} \
+ -Dsonar.host.url=https://sonarcloud.io \
+ -Dsonar.login=${SONARQUBE_TOKEN} \
+ else
+ echo "No Sonar PR analysis as this is not a pull request
+ fi
+
+ - save_cache:
+ key: dmp-sonar-pr-{{ checksum "pom.xml" }}
+ paths:
+ - ~/.m2
+
sonar:
working_directory: ~/fabric8io/dmp-sonar
docker:
@@ -37,7 +63,10 @@ jobs:
- checkout
- restore_cache:
key: dmp-sonar-{{ checksum "pom.xml" }}
- - run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN}
+ - run: |
+ mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar \
+ -Dsonar.host.url=https://sonarcloud.io \
+ -Dsonar.login=${SONARQUBE_TOKEN}
- save_cache:
key: dmp-sonar-{{ checksum "pom.xml" }}
paths:
@@ -52,3 +81,10 @@ workflows:
branches:
only: dmp.fabric8.io
- build
+ - sonar-pr:
+ requires:
+ - build
+ - sonar:
+ filters:
+ branches:
+ only: master
