diff --git a/.travis.yml b/.travis.yml index 1820a23f3a..683a26b255 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,6 @@ branches: only: - master - /release\/.*/ - - feature/ACS-457_travis-release-config env: global: @@ -237,7 +236,6 @@ jobs: - name: "Push to Nexus" stage: release if: false - install: travis_retry travis_wait 30 mvn -B -V install -DskipTests -Dmaven.javadoc.skip=true -Pinternal before_script: bash scripts/travis/verify_release_tag.sh script: travis_wait 40 bash scripts/travis/maven_release.sh diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index 8dde0a604a..3c5143bf19 100644 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -2,7 +2,13 @@ set -ev pushd "$(dirname "${BASH_SOURCE[0]}")/../../" -PROFILES="$([ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] && echo "-Pinternal" || echo "-PcommunityDocker" )" +source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" + +if [ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] && [ "${TRAVIS_BRANCH}" = "master" ] && isBranchBuild ; then + PROFILES="-Pinternal" +else + PROFILES="-PcommunityDocker" +fi mvn -B -V install -DskipTests -Dmaven.javadoc.skip=true "${PROFILES}" diff --git a/scripts/travis/build_functions.sh b/scripts/travis/build_functions.sh index d769a3148c..51f642b01f 100644 --- a/scripts/travis/build_functions.sh +++ b/scripts/travis/build_functions.sh @@ -65,6 +65,25 @@ function remoteBranchExists() { git ls-remote --exit-code --heads "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REMOTE_REPO}" "${BRANCH}" } +function identifyUpstreamSourceBranch() { + local UPSTREAM_REPO="${1}" + + # if it's a pull request, use the source branch name (if it exists) + if isPullRequestBuild && remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_PULL_REQUEST_BRANCH}" ; then + echo "${TRAVIS_PULL_REQUEST_BRANCH}" + exit 0 + fi + + # otherwise use the current branch name (or in case of PRs, the target branch name) + if remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_BRANCH}" ; then + echo "${TRAVIS_BRANCH}" + exit 0 + fi + + # if none of the previous exists, use the "master" branch + echo "master" +} + function pullUpstreamTag() { local UPSTREAM_REPO="${1}" local TAG="${2}" @@ -75,20 +94,8 @@ function pullUpstreamTag() { function pullAndBuildSameBranchOnUpstream() { local UPSTREAM_REPO="${1}" local EXTRA_BUILD_ARGUMENTS="${2}" - local SOURCE_BRANCH="$(isBranchBuild && echo "${TRAVIS_BRANCH}" || echo "${TRAVIS_PULL_REQUEST_BRANCH}")" - if ! remoteBranchExists "${UPSTREAM_REPO}" "${SOURCE_BRANCH}" ; then - printf "Branch \"%s\" not found on the %s repository\n" "${SOURCE_BRANCH}" "${UPSTREAM_REPO}" - #exit 1 - fi - - local SOURCE_BRANCH="${TRAVIS_BRANCH}" - if ! remoteBranchExists "${UPSTREAM_REPO}" "${SOURCE_BRANCH}" ; then - printf "Branch \"%s\" not found on the %s repository\n" "${SOURCE_BRANCH}" "${UPSTREAM_REPO}" - #exit 1 - fi - # TODO remove this line and enable the previous "exit" commands: - local SOURCE_BRANCH="master" + local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")" cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}"