From 75873f6400090795cefd51f8e469900d1df938f4 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 5 Feb 2018 22:06:35 +0100 Subject: [PATCH] Add PR properties to Artifactory build info --- cix.sh | 20 ++++++++---- pom.xml | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ travis.sh | 38 ++++++++++++---------- 3 files changed, 132 insertions(+), 22 deletions(-) diff --git a/cix.sh b/cix.sh index 024e4164539..942625d8a90 100755 --- a/cix.sh +++ b/cix.sh @@ -14,12 +14,18 @@ case "$RUN_ACTIVITY" in DB_ENGINE=$(sed "s/run-db-integration-tests-//g" <<< $RUN_ACTIVITY | cut -d \- -f 1) CATEGORY_GROUP=$(sed "s/run-db-integration-tests-//g" <<< $RUN_ACTIVITY | cut -d \- -f 2) - if [[ "$GITHUB_BRANCH" == "PULLREQUEST-"* ]] && [[ "$DB_ENGINE" != "postgresql93" ]]; then - # execute PR QA only on postgres + if [[ "$GITHUB_BRANCH" != "PULLREQUEST-"* ]] && [[ "$GITHUB_BRANCH" != "master" ]] && [[ "$GITHUB_BRANCH" != "branch-"* ]] && [[ "$GITHUB_BRANCH" != "dogfood-on-next" ]]; then + # do not execute QA tests on feature branch outside pull request exit 0 - elif [[ "$GITHUB_BRANCH" == "dogfood-on-next" ]] && [[ "$DB_ENGINE" != "postgresql93" ]]; then - # execute dogfood QA only on postgres + + elif [[ "$GITHUB_BRANCH" == "PULLREQUEST-"* ]] && [[ "$DB_ENGINE" != "postgresql93" ]]; then + # restrict QA tests to PostgreSQL on pull requests + exit 0 + + elif [[ "$GITHUB_BRANCH" == "dogfood-on-next" ]] && [[ "$DB_ENGINE" != "postgresql93" ]]; then + # restrict QA tests to PostgreSQL on dogfood branch exit 0 + else mvn clean package -B -e -V -f tests/plugins/pom.xml @@ -73,8 +79,10 @@ case "$RUN_ACTIVITY" in run-upgrade-tests-*) DB_ENGINE=$(sed "s/run-upgrade-tests-//g" <<< $RUN_ACTIVITY) - if [[ "$GITHUB_BRANCH" == "PULLREQUEST-"* ]] && [[ "$DB_ENGINE" != "postgresql93" ]]; then - exit 0 + if [[ "$GITHUB_BRANCH" != "master" ]] && [[ "$GITHUB_BRANCH" != "branch-"* ]] && [[ "$DB_ENGINE" != "postgresql93" ]]; then + # restrict upgrade tests to PostgreSQL on feature branches and dogfood + exit 0 + else ./run-upgrade-tests.sh "http://infra.internal.sonarsource.com/jenkins/orch-${DB_ENGINE}.properties" fi diff --git a/pom.xml b/pom.xml index d5bd1bae663..adf83a9be5c 100644 --- a/pom.xml +++ b/pom.xml @@ -1453,6 +1453,102 @@ tests/plugins + + + deploy-sonarsource + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-deploy-settings + + enforce + + + + + gitRepositoryName + You must set name of Git repository in your pom + + + ARTIFACTORY_URL + + + ARTIFACTORY_DEPLOY_REPO + + + ARTIFACTORY_DEPLOY_USERNAME + + + ARTIFACTORY_DEPLOY_PASSWORD + + + true + + + + + + + org.jfrog.buildinfo + artifactory-maven-plugin + ${version.artifactory.plugin} + + + build-info + + publish + + + + + *password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login* + + true + 60 + + + ${gitRepositoryName} + {{BUILD_NUMBER}} + {{PULL_REQUEST_BRANCH_TARGET}} + {{PULL_REQUEST_NUMBER}} + {{GIT_BRANCH}} + {{GIT_COMMIT}} + ${project.version} + + + true + false + true + project,provided + licences-control@sonarsource.com + + + ${env.ARTIFACTORY_URL} + ${env.ARTIFACTORY_DEPLOY_REPO} + ${env.ARTIFACTORY_DEPLOY_USERNAME} + ${env.ARTIFACTORY_DEPLOY_PASSWORD} + true + true + + + ${gitRepositoryName} + {{BUILD_NUMBER}} + {{CI_BUILD_URL|BUILD_URL}} + {{GIT_COMMIT}} + + + + + + + + + diff --git a/travis.sh b/travis.sh index 9ad2e069f49..f19d6be04ca 100755 --- a/travis.sh +++ b/travis.sh @@ -116,6 +116,19 @@ configureTravis # @TravisCI please provide the feature natively, like at AppVeyor or CircleCI ;-) cancel_branch_build_with_pr || if [[ $? -eq 1 ]]; then exit 0; fi +# configure environment variables for Artifactory +export GIT_COMMIT=$TRAVIS_COMMIT +export BUILD_NUMBER=$TRAVIS_BUILD_NUMBER +if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + export GIT_BRANCH=$TRAVIS_BRANCH + unset PULL_REQUEST_BRANCH_TARGET + unset PULL_REQUEST_NUMBER +else + export GIT_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH + export PULL_REQUEST_BRANCH_TARGET=$TRAVIS_BRANCH + export PULL_REQUEST_NUMBER=$TRAVIS_PULL_REQUEST +fi + case "$TARGET" in BUILD) @@ -148,9 +161,9 @@ BUILD) -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.buildNumber=$BUILD_NUMBER \ + -Dsonar.analysis.pipeline=$BUILD_NUMBER \ + -Dsonar.analysis.sha1=$GIT_COMMIT \ -Dsonar.analysis.repository=$TRAVIS_REPO_SLUG elif [[ "$TRAVIS_BRANCH" == "branch-"* ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then @@ -165,9 +178,9 @@ BUILD) -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.buildNumber=$BUILD_NUMBER \ + -Dsonar.analysis.pipeline=$BUILD_NUMBER \ + -Dsonar.analysis.sha1=$GIT_COMMIT \ -Dsonar.analysis.repository=$TRAVIS_REPO_SLUG elif [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN:-}" ]; then @@ -184,8 +197,8 @@ BUILD) -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.buildNumber=$BUILD_NUMBER \ + -Dsonar.analysis.pipeline=$BUILD_NUMBER \ -Dsonar.analysis.sha1=$TRAVIS_PULL_REQUEST_SHA \ -Dsonar.analysis.prNumber=$TRAVIS_PULL_REQUEST \ -Dsonar.analysis.repository=$TRAVIS_REPO_SLUG \ @@ -193,17 +206,10 @@ BUILD) -Dsonar.pullrequest.github.id=$TRAVIS_PULL_REQUEST \ -Dsonar.pullrequest.github.repository=$TRAVIS_REPO_SLUG - elif [[ "$TRAVIS_BRANCH" == "dogfood-on-"* ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then - echo 'Build dogfood branch' - - mvn org.jacoco:jacoco-maven-plugin:prepare-agent deploy \ - $MAVEN_ARGS \ - -Pdeploy-sonarsource,release - else echo 'Build feature branch or external pull request' - mvn install $MAVEN_ARGS -Dsource.skip=true + mvn deploy $MAVEN_ARGS -Dsource.skip=true -Pdeploy-sonarsource fi ./run-integration-tests.sh "Lite" "" -- 2.39.5