diff --git a/.gitignore b/.gitignore index 0ab642813c..f9983e601e 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,7 @@ alf_data/ helm/alfresco-content-services-community/charts/* helm/alfresco-content-services-community/requirements.lock -helm/alfresco-content-services-community*.tgz \ No newline at end of file +helm/alfresco-content-services-community*.tgz + +# Travis deployment folder +deploy_dir \ No newline at end of file diff --git a/.travis.settings.xml b/.travis.settings.xml new file mode 100644 index 0000000000..48b88983e0 --- /dev/null +++ b/.travis.settings.xml @@ -0,0 +1,49 @@ + + + + alfresco-internal + + true + + + + alfresco-internal + + true + + + true + + Alfresco Internal Repository + https://artifacts.alfresco.com/nexus/content/groups/internal + + + + + alfresco-internal + Alfresco Internal Repository + https://artifacts.alfresco.com/nexus/content/groups/public + + + + + + + + + alfresco-internal + ${env.MAVEN_USERNAME} + ${env.MAVEN_PASSWORD} + + + quay.io + ${env.QUAY_USERNAME} + ${env.QUAY_PASSWORD} + + + docker.io + ${env.DOCKERHUB_USERNAME} + ${env.DOCKERHUB_PASSWORD} + + + diff --git a/.travis.yml b/.travis.yml index da39c4e70d..f151e21a7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ dist: xenial -sudo: required +os: linux language: java jdk: - openjdk11 @@ -10,19 +10,33 @@ services: cache: directories: - $HOME/.m2 - +# the cache can grow constantly +before_cache: + - rm -rf $HOME/.m2/repository/org/alfresco/acs-community-packaging env: global: - VERSION_EDITION=Community - + # Must be in the format - ie. 6.3.0-repo-xxxx-x or 6.3.0-A-x + - RELEASE_VERSION= + - DEVELOPMENT_VERSION= + - COMM_RELEASE_VERSION= branches: only: - master - develop -matrix: +stages: + - name: test + if: commit_message !~ /\[skip tests\]/ + - release + - publish + +before_install: "cp .travis.settings.xml $HOME/.m2/settings.xml" + +jobs: include: - - name: "WhiteSource scan" + - stage: test + name: "WhiteSource scan" # only on develop and if it is not a PR if: fork = false AND branch = develop AND type != pull_request install: @@ -90,3 +104,43 @@ matrix: - ./tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" script: - travis_wait 30 mvn install -q -f tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false + - stage: Release + name: "Maven release" + if: commit_message ~= /\[release\]/ AND fork = false AND branch =~ ^(master|develop)$ AND type != pull_request + install: travis_retry travis_wait 40 mvn clean install -DskipTests=true "-Dversion.edition=${VERSION_EDITION}" -Dmaven.javadoc.skip=true -B -V + # Fail the job if there is a docker image tag that matches the RELEASE_VERSION (or project version in the POM if not set) + before_script: ./scripts/travis/verify_release_tag.sh + script: travis_wait 40 ./scripts/travis/maven_release.sh ${RELEASE_VERSION} ${DEVELOPMENT_VERSION} + # Copy alfresco.war and the distribution zip to deploy_dir + before_deploy: + # Move the final artifacts to a single folder (deploy_dir) to be copied to S3 + - mkdir -p deploy_dir + - cp war/target/alfresco.war deploy_dir + - cp distribution/target/*-distribution*.zip deploy_dir + deploy: + - provider: s3 + access_key_id: ${AWS_STAGING_ACCESS_KEY} + secret_access_key: ${AWS_STAGING_SECRET_KEY} + bucket: "alfresco-artefacts-staging" + region: "eu-west-1" + skip_cleanup: true + acl: private + local_dir: deploy_dir + upload_dir: "alfresco-content-services-community/release/${TRAVIS_BRANCH}/${TRAVIS_BUILD_NUMBER}" + on: + all_branches: true + condition: $TRAVIS_BRANCH =~ ^(master|develop)$ + - stage: "Publish" + name: "Copy to S3 Release" + if: commit_message ~= /\[publish\]/ AND fork = false AND branch = master AND type != pull_request + # Nothing to build/install as we are just copying from S3 buckets + install: skip + script: skip + before_deploy: pip install awscli + delpoy: + - provider: script + script: ./scripts/travis/copy_to_release_bucket.sh ${TRAVIS_BUILD_NUMBER} ${TRAVIS_BRANCH} + on: + branch: master + + diff --git a/docker-alfresco/pom.xml b/docker-alfresco/pom.xml index 25129d6dfe..bc207cf182 100644 --- a/docker-alfresco/pom.xml +++ b/docker-alfresco/pom.xml @@ -340,6 +340,7 @@ + quay.io ${image.name}:${project.version} ${image.registry} @@ -347,6 +348,7 @@ + dockerhub ${image.name}:${project.version} ${project.basedir}/ @@ -369,6 +371,4 @@ - - - \ No newline at end of file + diff --git a/pom.xml b/pom.xml index 0c86f442ac..74a84d1e81 100644 --- a/pom.xml +++ b/pom.xml @@ -46,8 +46,8 @@ - scm:git:git@github.com:Alfresco/acs-community-packaging.git - scm:git:git@github.com:Alfresco/acs-community-packaging.git + scm:git:https://github.com/Alfresco/acs-community-packaging.git + scm:git:https://github.com/Alfresco/acs-community-packaging.git https://github.com/Alfresco/acs-community-packaging HEAD @@ -116,6 +116,8 @@ 1.6 1.5 2.3 + + 11 diff --git a/scripts/travis/copy_to_release_bucket.sh b/scripts/travis/copy_to_release_bucket.sh new file mode 100755 index 0000000000..f04dc95162 --- /dev/null +++ b/scripts/travis/copy_to_release_bucket.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -ev + +if [ -z ${COMM_RELEASE_VERSION} ] || [ -z ${RELEASE_VERSION} ]; +then + echo "Please provide a COMM_RELEASE_VERSION and RELEASE_VERSION in the format - (6.3.0-EA or 6.3.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 + +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 \ No newline at end of file diff --git a/scripts/travis/maven_release.sh b/scripts/travis/maven_release.sh new file mode 100755 index 0000000000..f7e7aca416 --- /dev/null +++ b/scripts/travis/maven_release.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -e + +releaseVersion=$1 +developmentVersion=$2 +scm_path=$(mvn help:evaluate -Dexpression=project.scm.url -q -DforceStdout) + +# 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 - (6.3.0-EA or 6.3.0-SNAPSHOT)" + exit -1 +else + mvn --batch-mode \ + -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} " \ + release:clean release:prepare release:perform \ + -Prelease +fi diff --git a/scripts/travis/verify_release_tag.sh b/scripts/travis/verify_release_tag.sh new file mode 100755 index 0000000000..51086b8ec7 --- /dev/null +++ b/scripts/travis/verify_release_tag.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -e + +if [ -v ${RELEASE_VERSION} ]||[ -z ${RELEASE_VERSION} ]; then + echo "Please provide a RELEASE_VERSION in the format - (6.3.0-EA or 6.3.0-SNAPSHOT)" + 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" + +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 +} + +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 diff --git a/war/pom.xml b/war/pom.xml index 71bb414646..ccc5b792b9 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -265,6 +265,20 @@ + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.1.1 + + ${maven.build.sourceVersion} + + + + + maven-release-plugin + 2.5.3 + org.codehaus.mojo license-maven-plugin