Skip to content

Commit

Permalink
Activate SonarQube branch analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
racodond committed Feb 15, 2018
1 parent 8a26e00 commit 44bb4e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -18,6 +18,5 @@ env:
cache:
directories:
- '$HOME/.m2/repository'
- '$HOME/.sonar/cache'

script: ./travis.sh
28 changes: 15 additions & 13 deletions travis.sh
Expand Up @@ -4,18 +4,20 @@ set -euo pipefail

mvn -B clean install -Pits -Dsonar.runtimeVersion=$SQ_VERSION

if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$SQ_VERSION" == "LTS" ]; then
mvn -B sonar:sonar \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \
-Dsonar.github.repository=$TRAVIS_REPO_SLUG \
-Dsonar.github.oauth=$GITHUB_TOKEN \
-Dsonar.login=$SONAR_TOKEN \
-Dsonar.organization=racodond-github
if [ "$SQ_VERSION" == "LTS" ]; then

mvnCommand='mvn -B sonar:sonar'
commonArgs="-Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dsonar.organization=racodond-github"
githubArgs="-Dsonar.analysis.mode=preview -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST -Dsonar.github.repository=$TRAVIS_REPO_SLUG -Dsonar.github.oauth=$GITHUB_TOKEN"
branchArgs=''

if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS_BRANCH" != "master" ]; then
branchArgs="-Dsonar.branch.name=$TRAVIS_BRANCH -Dsonar.branch.target=master"
fi
eval $mvnCommand $commonArgs $branchArgs
else
eval $mvnCommand $commonArgs $githubArgs
fi

elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$SQ_VERSION" == "LTS" ]; then
mvn -B sonar:sonar \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$SONAR_TOKEN \
-Dsonar.organization=racodond-github
fi

0 comments on commit 44bb4e2

Please sign in to comment.