CezarLeahu 3a0725ee77
ACS-457: Build linkage, tagging and release (#4)
* ACS-457: Build linkage, tagging and release

- update .travis.settings.xml

* ACS-457: Build linkage, tagging and release

- add cleanup_cache.sh script

* ACS-457: Build linkage, tagging and release

- add init.sh script for before_install job phases

* ACS-457: Build linkage, tagging and release

- add build.sh script for install job phases

* ACS-457: Build linkage, tagging and release

- minor updates on the older travis and veracode scripts

* ACS-457: Build linkage, tagging and release

- reorganized and updated .travis.yml

* ACS-457: Build linkage, tagging and release

- add remote branch validation in the trigger_travis.sh script

* ACS-457: Build linkage, tagging and release

- update and propagate branch version numbers during the build

* ACS-457: Build linkage, tagging and release

- enable docker image squash for all image builds

* ACS-457: Build linkage, tagging and release

- shellcheck CI scripts

* ACS-457: Build linkage, tagging and release

- switch to TEST pom versions

* ACS-457: Build linkage, tagging and release

- post-merge fixes

* ACS-457: Build linkage, tagging and release

- update trigger_travis.sh scrips so they offer more debug info

* ACS-457: Build linkage, tagging and release

- clone upstream repositories with "--depth=1" (no history needed)
- add "-Dmaven.javadoc.skip=true" options in the build scripts

* ACS-457: Build linkage, tagging and release

- remove <scm> configuration from sub-modules
- remove <distributionManagement> configurations from submodules
- remove <repository> configuration from poms
- remove unnecessary and unused POM profiles

* ACS-457: Build linkage, tagging and release

- add pom <pluginManagement> section
- removed some plugin versions from downstream modules
- add a single common configuration for the *maven-relese-plugin*

* ACS-457: Build linkage, tagging and release

- post-merge fixes

* ACS-457: Build linkage, tagging and release

- update and reorganize the fabric8-maven-plugin configuration

* ACS-457: Build linkage, tagging and release

- extra debug info on the trigger_travis.sh scripts

* ACS-457: Build linkage, tagging and release

- modify the build.sh scripts so they checkout the upstream project tag

* ACS-457: Build linkage, tagging and release

- test different token variable for propagating builds

* ACS-457: Build linkage, tagging and release

- re-implement build.sh script logic to support PRs & branch builds
- restricted the build.sh script capabilities
- moved build functions to a separate .sh file

* ACS-457: Build linkage, tagging and release

- update release scripts

* ACS-457: Build linkage, tagging and release

- debug build scripts

* ACS-457: Build linkage, tagging and release

- fix build scripts

* ACS-457: Build linkage, tagging and release

- setup/update the S3 publishing jobs

* ACS-457: Build linkage, tagging and release

- update build scripts
- remove a few unnecessary TODOs

* ACS-457: Build linkage, tagging and release

- disable release jobs for now
2020-08-12 00:24:51 +03:00

97 lines
2.3 KiB
Bash

#!/usr/bin/env bash
function isPullRequestBuild() {
test "${TRAVIS_PULL_REQUEST}" != "false"
}
function isBranchBuild() {
test "${TRAVIS_PULL_REQUEST}" = "false"
}
function cloneRepo() {
local REPO="${1}"
local TAG_OR_BRANCH="${2}"
# clone the repository branch/tag
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null
rm -rf "$(basename "${REPO%.git}")"
git clone -b "${TAG_OR_BRANCH}" --depth=1 "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}"
popd >/dev/null
}
function retrievePomParentVersion() {
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
sed -n '/<parent>/,/<\/parent>/p' pom.xml \
| sed -n '/<version>/,/<\/version>/p' \
| tr -d '\n' \
| grep -oP '(?<=<version>).*(?=</version>)' \
| xargs
popd >/dev/null
}
function retrievePomProperty() {
local KEY="${1}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
sed -n '/<properties>/,/<\/properties>/p' pom.xml \
| sed -n "/<${KEY}>/,/<\/${KEY}>/p" \
| tr -d '\n' \
| grep -oP "(?<=<${KEY}>).*(?=</${KEY}>)" \
| xargs
popd >/dev/null
}
function evaluatePomProperty() {
local KEY="${1}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
mvn -B -q help:evaluate -Dexpression="${KEY}" -DforceStdout
popd >/dev/null
}
function remoteBranchExists() {
local REMOTE_REPO="${1}"
local BRANCH="${2}"
git ls-remote --exit-code --heads "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REMOTE_REPO}" "${BRANCH}"
}
function pullUpstreamTag() {
local UPSTREAM_REPO="${1}"
local TAG="${2}"
cloneRepo "${UPSTREAM_REPO}" "${TAG}"
}
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
cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
cd "$(basename "${UPSTREAM_REPO%.git}")"
mvn -B -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS}
mvn -B -V install -DskipTests -f packaging/tests/pom.xml
popd
}