Смешивание с частью script
в .travis.yml
работает для меня.
Важная часть :
script:
- cmdExtra=""; if [ $TRAVIS_BRANCH = "master" ]; then cmdExtra="<your-sonar-trigger-here>"; fi; <your-cmd-here> $cmdExtra
Это полный примерJava-проект на основе Maven:
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'