export MAVEN_OPTS="-Xmx1G -Xms128m"
MAVEN_ARGS="-T 1C -Dmaven.test.redirectTestOutputToFile=false -Dsurefire.useFile=false -B -e -V -DbuildVersion=$BUILD_VERSION -Dtests.es.logger.level=WARN -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
-
- # Fetch all commit history so that SonarQube has exact blame information
- # for issue auto-assignment
- # This command can fail with "fatal: --unshallow on a complete repository does not make sense"
- # if there are not enough commits in the Git repository (even if Travis executed git clone --depth 50).
- # For this reason errors are ignored with "|| true"
- git fetch --unshallow || true
-
-
if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo 'Build and analyze master'
- mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \
+ mvn deploy \
$MAVEN_ARGS \
-Pdeploy-sonarsource,release
-
- mvn sonar:sonar \
- -Dsonar.host.url=$SONAR_HOST_URL \
- -Dsonar.login=$SONAR_TOKEN \
- -Dsonar.projectVersion=$INITIAL_VERSION \
- -Dsonar.analysis.buildNumber=$TRAVIS_BUILD_NUMBER \
- -Dsonar.analysis.pipeline=$TRAVIS_BUILD_NUMBER \
- -Dsonar.analysis.sha1=$TRAVIS_COMMIT \
- -Dsonar.analysis.repository=$TRAVIS_REPO_SLUG
elif [[ "$TRAVIS_BRANCH" == "branch-"* ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo 'Build release branch'
- mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \
+ mvn deploy \
$MAVEN_ARGS \
-Pdeploy-sonarsource,release
- mvn sonar:sonar \
- -Dsonar.host.url=$SONAR_HOST_URL \
- -Dsonar.login=$SONAR_TOKEN \
- -Dsonar.branch.name=$TRAVIS_BRANCH \
- -Dsonar.projectVersion=$INITIAL_VERSION \
- -Dsonar.analysis.buildNumber=$TRAVIS_BUILD_NUMBER \
- -Dsonar.analysis.pipeline=$TRAVIS_BUILD_NUMBER \
- -Dsonar.analysis.sha1=$TRAVIS_COMMIT \
- -Dsonar.analysis.repository=$TRAVIS_REPO_SLUG
-
elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN:-}" ]; then
echo 'Build and analyze internal pull request'
- mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \
+ mvn deploy \
$MAVEN_ARGS \
-Dsource.skip=true \
-Pdeploy-sonarsource
- # analysis to decorate GitHub pull request
- # (need support of standard analysis mode in GH plugin)
- mvn sonar:sonar \
- -Dsonar.host.url=$SONAR_HOST_URL \
- -Dsonar.login=$SONAR_TOKEN \
- -Dsonar.analysis.mode=preview \
- -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \
- -Dsonar.github.repository=$TRAVIS_REPO_SLUG \
- -Dsonar.github.oauth=$GITHUB_TOKEN
-
- mvn sonar:sonar \
- -Dsonar.host.url=$SONAR_HOST_URL \
- -Dsonar.login=$SONAR_TOKEN \
- -Dsonar.branch.name=$TRAVIS_PULL_REQUEST_BRANCH \
- -Dsonar.branch.target=$TRAVIS_BRANCH \
- -Dsonar.analysis.buildNumber=$TRAVIS_BUILD_NUMBER \
- -Dsonar.analysis.pipeline=$TRAVIS_BUILD_NUMBER \
- -Dsonar.analysis.sha1=$TRAVIS_PULL_REQUEST_SHA \
- -Dsonar.analysis.prNumber=$TRAVIS_PULL_REQUEST \
- -Dsonar.analysis.repository=$TRAVIS_REPO_SLUG
else
echo 'Build feature branch or external pull request'