REPO-5271 Backport new project structure to master (#1067)

Original version was: 7.0.0-A3 (but keystore changes where cherry picked into the branch)

Uses alfresco-community-repo project structure rather than alfresco-core, alfresco-data-model, alfresco-repository and alfresco-remote-api.

Simplify dependencies, which flow downstream rather than being overridden in packaging.
Content repo base image separated from acs-community-packaging.
Licenses and default key store moved upstream. Allows use in upstream images.
TAS tests moved upstream, where they are content repository specific.
This commit is contained in:
Alan Davis
2020-10-04 19:42:45 +01:00
committed by GitHub
parent 726d3aa3e6
commit 2cb08d3ead
550 changed files with 1086 additions and 90936 deletions

53
scripts/travis/build.sh Normal file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
echo "=========================== Starting Build Script ==========================="
PS4="\[\e[35m\]+ \[\e[m\]"
set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh"
DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-community-repo.version")"
# Either both the parent and the upstream dependency are the same, or else fail the build
if [ "${DEPENDENCY_VERSION}" != "$(retrievePomParentVersion)" ]; then
printf "Upstream dependency version (%s) is different then the project parent version!\n" "${DEPENDENCY_VERSION}"
exit 1
fi
# Prevent merging of any SNAPSHOT dependencies into the master or the release/* branches
if [[ $(isPullRequestBuild) && "${DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ && "${TRAVIS_BRANCH}" =~ ^master$|^release/.+$ ]] ; then
printf "PRs with SNAPSHOT dependencies are not allowed into master or release branches\n"
exit 1
fi
# Prevent release jobs from starting when there are SNAPSHOT upstream dependencies
if [[ "${DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && [ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] ; then
printf "Cannot release project with SNAPSHOT dependencies!\n"
exit 1
fi
UPSTREAM_REPO="github.com/Alfresco/alfresco-community-repo.git"
# For release jobs, check if the upstream dependency is the latest tag on the upstream repository (on the same branch)
if isBranchBuild && [ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] && [ "${DEPENDENCY_VERSION}" != "$(retieveLatestTag "${UPSTREAM_REPO}" "${TRAVIS_BRANCH}")" ] ; then
printf "Upstream dependency is not up to date with %s / %s\n" "${UPSTREAM_REPO}" "${TRAVIS_BRANCH}"
exit 1
fi
# Search, checkout and build the same branch on the upstream project in case of SNAPSHOT dependencies
# Otherwise, checkout the upstream tag and build its Docker image (use just "mvn package", without "mvn install")
if [[ "${DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then
pullAndBuildSameBranchOnUpstream "${UPSTREAM_REPO}" "-PcommunityDocker"
else
pullUpstreamTagAndBuildDockerImage "${UPSTREAM_REPO}" "${DEPENDENCY_VERSION}" "-PcommunityDocker"
fi
# Build the current project
mvn -B -V -q install -DskipTests -Dmaven.javadoc.skip=true -PcommunityDocker \
$([[ "${DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && echo "-Drepo.image.tag=latest")
popd
set +vex
echo "=========================== Finishing Build Script =========================="

View File

@@ -0,0 +1,146 @@
#!/usr/bin/env bash
set +vx
function isPullRequestBuild() {
test "${TRAVIS_PULL_REQUEST}" != "false"
}
function isBranchBuild() {
test "${TRAVIS_PULL_REQUEST}" = "false"
}
function cloneRepo() {
local REPO="${1}"
local TAG_OR_BRANCH="${2}"
printf "Clonning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"
# 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}" &>/dev/null
}
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}"
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="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")"
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
}
function retieveLatestTag() {
local REPO="${1}"
local BRANCH="${2}"
local LOCAL_PATH="/tmp/$(basename "${REPO%.git}")"
git clone -q -b "${BRANCH}" "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}" "${LOCAL_PATH}"
pushd "${LOCAL_PATH}" >/dev/null
git describe --abbrev=0 --tags
popd >/dev/null
rm -rf "${LOCAL_PATH}"
}
set -vx

View 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"

View File

@@ -1,17 +1,31 @@
#!/usr/bin/env bash
set -ev
echo "=========================== Starting Copy to Release Bucket Script ==========================="
PS4="\[\e[35m\]+ \[\e[m\]"
set -vex
if [ -z ${COMM_RELEASE_VERSION} ] || [ -z ${RELEASE_VERSION} ];
then
echo "Please provide a COMM_RELEASE_VERSION and RELEASE_VERSION in the format <acs-version>-<additional-info> (6.3.0-EA or 6.3.0-SNAPSHOT)"
exit -1
#
# Copy from S3 Release bucket to S3 eu.dl bucket
#
if [ -z "${RELEASE_VERSION}" ]; then
echo "Please provide a RELEASE_VERSION in the format <acs-version>-<additional-info> (7.0.0-EA or 7.0.0-SNAPSHOT)"
exit 1
fi
build_number=$1
branch_name=$2
build_stage=release
SOURCE=s3://alfresco-artefacts-staging/alfresco-content-services-community/$build_stage/$branch_name/$build_number
DESTINATION=s3://eu.dl.alfresco.com/release/community/$COMM_RELEASE_VERSION-build-$build_number
SOURCE="s3://alfresco-artefacts-staging/alfresco-content-services-community/release/${TRAVIS_BRANCH}/${TRAVIS_BUILD_NUMBER}"
DESTINATION="s3://eu.dl.alfresco.com/release/community/${RELEASE_VERSION}-build-${TRAVIS_BUILD_NUMBER}"
printf "\n%s\n%s\n" "${SOURCE}" "${DESTINATION}"
aws s3 cp --acl private \
"${SOURCE}/alfresco.war" \
"${DESTINATION}/alfresco.war"
aws s3 cp --acl private \
"${SOURCE}/alfresco-content-services-community-distribution-${RELEASE_VERSION}.zip" \
"${DESTINATION}/alfresco-content-services-community-distribution-${RELEASE_VERSION}.zip"
set +vex
echo "=========================== Finishing Copy to Release Bucket Script =========================="
aws s3 cp --acl private $SOURCE/alfresco.war $DESTINATION/alfresco.war
aws s3 cp --acl private $SOURCE/alfresco-content-services-community-distribution-$RELEASE_VERSION.zip $DESTINATION/alfresco-content-services-community-distribution-$RELEASE_VERSION.zip

25
scripts/travis/init.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
echo "=========================== Starting Init Script ==========================="
PS4="\[\e[35m\]+ \[\e[m\]"
set -vex
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 "${DOCKERHUB_PASSWORD}" | docker login -u="${DOCKERHUB_USERNAME}" --password-stdin
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' ')
popd
set +vex
echo "=========================== Finishing Init Script =========================="

View File

@@ -1,31 +1,32 @@
#!/usr/bin/env bash
set -e
echo "=========================== Starting Release Script ==========================="
PS4="\[\e[35m\]+ \[\e[m\]"
set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
releaseVersion=$1
developmentVersion=$2
scm_path=$(mvn help:evaluate -Dexpression=project.scm.url -q -DforceStdout)
if [ -z "${RELEASE_VERSION}" ] || [ -z "${DEVELOPMENT_VERSION}" ]; then
echo "Please provide a Release and Development version in the format <acs-version>-<additional-info> (7.0.0-EA or 7.0.0-SNAPSHOT)"
exit 1
fi
# Use full history for release
git checkout -B "${TRAVIS_BRANCH}"
# Add email to link commits to user
git config user.email "${GIT_EMAIL}"
if [ -z ${releaseVersion} ] || [ -z ${developmentVersion} ];
then echo "Please provide a Release and Development verison in the format <acs-version>-<additional-info> (6.3.0-EA or 6.3.0-SNAPSHOT)"
exit -1
else
mvn --batch-mode \
-PfullBuild,all-tas-tests \
-Dusername="${GIT_USERNAME}" \
-Dpassword="${GIT_PASSWORD}" \
-DreleaseVersion=${releaseVersion} \
-DdevelopmentVersion=${developmentVersion} \
-Dbuild-number=${TRAVIS_BUILD_NUMBER} \
-Dbuild-name="${TRAVIS_BUILD_STAGE_NAME}" \
-Dscm-path=${scm_path} \
-DscmCommentPrefix="[maven-release-plugin][skip ci]" \
-DskipTests \
"-Darguments=-DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER} '-Dbuild-name=${TRAVIS_BUILD_STAGE_NAME}' -Dscm-path=${scm_path} -PfullBuild,all-tas-tests" \
release:clean release:prepare release:perform \
-Prelease
fi
mvn -B \
-Prelease,fullBuild,all-tas-tests \
-DreleaseVersion="${RELEASE_VERSION}" \
-DdevelopmentVersion="${DEVELOPMENT_VERSION}" \
"-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}"
popd
set +vex
echo "=========================== Finishing Release Script =========================="

View File

@@ -1,31 +1,52 @@
#!/usr/bin/env bash
set -e
echo "=========================== Starting Verify Release Tag Script ==========================="
PS4="\[\e[35m\]+ \[\e[m\]"
set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
if [ -v ${RELEASE_VERSION} ]||[ -z ${RELEASE_VERSION} ]; then
echo "Please provide a RELEASE_VERSION in the format <acs-version>-<additional-info> (6.3.0-EA or 6.3.0-SNAPSHOT)"
exit -1
#
# Check that the version to be released does not already have a docker tag.
#
if [ -z "${RELEASE_VERSION}" ]; then
echo "Please provide a RELEASE_VERSION in the format <acs-version>-<additional-info> (7.0.0-EA or 7.0.0-SNAPSHOT)"
exit 1
fi
if git rev-parse "${RELEASE_VERSION}^{tag}" &>/dev/null ; then
echo "The RELEASE_VERSION tag \"${RELEASE_VERSION}\" already exists in the git project"
exit 1
fi
# get the image name from the pom file
alfresco_docker_image=$(mvn help:evaluate -f ./docker-alfresco/pom.xml -Dexpression=image.name -q -DforceStdout)
docker_image_full_name="$alfresco_docker_image:$RELEASE_VERSION"
ALFRESCO_DOCKER_IMAGE="$(mvn -B -q help:evaluate -f ./docker-alfresco/pom.xml -Dexpression=image.name -DforceStdout)"
DOCKER_IMAGE_FULL_NAME="${ALFRESCO_DOCKER_IMAGE}:${RELEASE_VERSION}"
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' | egrep -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
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
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"
echo "The ${RELEASE_VERSION} tag was not found"
fi
popd
set +vex
echo "=========================== Finishing Verify Release Tag Script =========================="