Files
alfresco-community-repo/scripts/travis/build_functions.sh
Alan Davis 8f50904785 REPO-5271 Backport new structure to relaese/6.2.1 (#20)
- Simplify dependencies and standardise order
- README updated
- Green builds
- Changes to make Jars in enterprise war match
- Changes to make files in enterprise image match
- Added travis_wait 40 to the initial build as it can take 20 minutes to download artifacts
- Removed NodesTest.siteConsumerWillGet403OnFileWithDisabledInherittedPermissions introduced in 7.0.0 and fails in earlier versions.
- GetSiteMember[s]Tests changed in 7.0.0. Setting test back to previous values.
2020-09-27 10:53:41 +01:00

121 lines
3.0 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 pullUpstreamTagAndBuildDockerImage() {
local UPSTREAM_REPO="${1}"
local TAG="${2}"
local EXTRA_BUILD_ARGUMENTS="${3}"
cloneRepo "${UPSTREAM_REPO}" "${TAG}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
cd "$(basename "${UPSTREAM_REPO%.git}")"
mvn -B -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS}
popd
}
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"
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 -q install -DskipTests -f packaging/tests/pom.xml
popd
}