mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
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
This commit is contained in:
9
scripts/travis/build.sh
Normal file
9
scripts/travis/build.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
PROFILES="$([ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] && echo "-Pinternal" || echo "-PcommunityDocker" )"
|
||||
|
||||
mvn -B -V install -DskipTests -Dmaven.javadoc.skip=true "${PROFILES}"
|
||||
|
||||
|
96
scripts/travis/build_functions.sh
Normal file
96
scripts/travis/build_functions.sh
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/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
|
||||
}
|
||||
|
19
scripts/travis/cleanup_cache.sh
Normal file
19
scripts/travis/cleanup_cache.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/acs-community-packaging"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-community-repo"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-community-repo-*"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-core"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-data-model"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-remote-api"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-repo-*"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-repository"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-remote-api"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-repository"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/content-services"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/content-services*"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/content-services-community"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/tas/alfresco-community-repo-*-test"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/tas/alfresco-enterprise-repo-*-test"
|
||||
|
18
scripts/travis/init.sh
Normal file
18
scripts/travis/init.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
# Maven Setup
|
||||
mkdir -p "${HOME}/.m2" && cp -f .travis.settings.xml "${HOME}/.m2/settings.xml"
|
||||
find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT*" | xargs -r -l rm -rf
|
||||
|
||||
# Docker Logins
|
||||
echo "${QUAY_PASSWORD}" | docker login -u="${QUAY_USERNAME}" --password-stdin quay.io
|
||||
|
||||
# Enable experimental docker features (for the image squash option)
|
||||
echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
|
||||
sudo service docker restart
|
||||
|
||||
# not helpful in this script
|
||||
# export HOST_IP=$(hostname -I | cut -f1 -d' ')
|
||||
|
17
scripts/travis/maven_release.sh
Executable file
17
scripts/travis/maven_release.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
|
||||
# Use full history for release
|
||||
git checkout -B "${TRAVIS_BRANCH}"
|
||||
# Add email to link commits to user
|
||||
git config user.email "${GIT_EMAIL}"
|
||||
|
||||
# Run the release plugin - with "[skip ci]" in the release commit message
|
||||
mvn -B \
|
||||
-Prelease,fullBuild,all-tas-tests \
|
||||
"-Darguments=-Prelease,fullBuild,all-tas-tests -DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER}" \
|
||||
release:clean release:prepare release:perform \
|
||||
-DscmCommentPrefix="[maven-release-plugin][skip ci] " \
|
||||
-Dusername="${GIT_USERNAME}" \
|
||||
-Dpassword="${GIT_PASSWORD}"
|
||||
|
48
scripts/travis/trigger_travis.sh
Executable file
48
scripts/travis/trigger_travis.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
|
||||
USER=${1}
|
||||
REPO=${2}
|
||||
BRANCH=${3}
|
||||
|
||||
if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
|
||||
echo "Downstream projects shouldn't be triggered from PR builds"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! git ls-remote --exit-code --heads "https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/${USER}/${REPO}.git" "${BRANCH}" ; then
|
||||
echo "Branch \"${BRANCH}\" not found on the downstream repository ${USER}/${REPO}. Exiting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
URL="https://api.travis-ci.com/repo/${USER}%2F${REPO}/requests"
|
||||
BODY="{
|
||||
\"request\": {
|
||||
\"branch\":\"${BRANCH}\"
|
||||
}}"
|
||||
|
||||
printf "Travis API call:\n URL: %s\n Body: %s\n\n" "${URL}" "${BODY}"
|
||||
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Travis-API-Version: 3" \
|
||||
-H "Authorization: token ${TRAVIS_ACCESS_TOKEN_TEMP}" \
|
||||
-d "${BODY}" \
|
||||
"${URL}" \
|
||||
| tee /tmp/travis-request-output.txt
|
||||
|
||||
cat /tmp/travis-request-output.txt
|
||||
|
||||
if grep -q '"@type": "error"' /tmp/travis-request-output.txt; then
|
||||
echo "Error when triggering build..."
|
||||
exit 2
|
||||
fi
|
||||
if grep -q 'access denied' /tmp/travis-request-output.txt; then
|
||||
echo "Access denied when triggering build..."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
38
scripts/travis/verify_release_tag.sh
Executable file
38
scripts/travis/verify_release_tag.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
|
||||
#
|
||||
# Check that the version to be released does not already have a docker tag.
|
||||
#
|
||||
|
||||
POM_VERSION=$(mvn -B -q help:evaluate -Dexpression=project.version -DforceStdout)
|
||||
printf "POM version: %s\n" "${POM_VERSION}"
|
||||
|
||||
IMAGE_TAG="${POM_VERSION%-SNAPSHOT}"
|
||||
|
||||
# get the image name from the pom file
|
||||
ALFRESCO_DOCKER_IMAGE="$(mvn -B -q help:evaluate -f ./packaging/docker-alfresco/pom.xml -Dexpression=image.name -DforceStdout)"
|
||||
DOCKER_IMAGE_FULL_NAME="${ALFRESCO_DOCKER_IMAGE}:${IMAGE_TAG}"
|
||||
|
||||
function docker_image_exists() {
|
||||
local IMAGE_FULL_NAME="${1}"; shift
|
||||
local WAIT_TIME="${1:-5}"
|
||||
local SEARCH_TERM='Pulling|is up to date|not found'
|
||||
|
||||
echo "Looking to see if ${IMAGE_FULL_NAME} already exists..."
|
||||
local RESULT=$( (timeout --preserve-status "${WAIT_TIME}" docker 2>&1 pull "${IMAGE_FULL_NAME}" &) | grep -v 'Pulling repository' | grep -E -o "${SEARCH_TERM}")
|
||||
|
||||
test "${RESULT}" || { echo "Timed out too soon. Try using a wait_time greater than ${WAIT_TIME}..."; return 1 ;}
|
||||
if echo "${RESULT}" | grep -vq 'not found'; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
if docker_image_exists "${DOCKER_IMAGE_FULL_NAME}" ; then
|
||||
echo "Tag ${RELEASE_VERSION} already pushed, release process will interrupt."
|
||||
exit 1
|
||||
else
|
||||
echo "The ${RELEASE_VERSION} tag was not found"
|
||||
fi
|
Reference in New Issue
Block a user