Reputation: 3894
As I only have the free CE account on SonarQube.com (SQ), I can not let it build any branch other then master
.
How do I setup my .travis.yml
so it triggers SQ only when building the master
branch, but still builds other branches (just without triggering SQ)?
Upvotes: 0
Views: 136
Reputation: 3894
Medling with the script
part in .travis.yml
works for me.
The important part is:
script:
- cmdExtra=""; if [ $TRAVIS_BRANCH = "master" ]; then cmdExtra="<your-sonar-trigger-here>"; fi; <your-cmd-here> $cmdExtra
This is a complete example for a Maven based Java project:
language: java
sudo: false # faster builds
addons:
sonarcloud:
organization: "myOrganizationId"
token:
secure: "134f51f3451f3451ffe12f3124123123123123123123"
jdk:
- openjdk8
script:
# NOTE JaCoCo is used to have code coverage, the agent has to be activated
# NOTE The SonarCube Community Edition (free plan) only supports branch "master".
- cmdExtra=""; if [ $TRAVIS_BRANCH = "master" ]; then cmdExtra="sonar:sonar"; fi; mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package $cmdExtra
cache:
directories:
- '$HOME/.m2/repository'
- '$HOME/.sonar/cache'
Upvotes: 1