diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bece0a7edbdb2b372839e64cdb483b0fd2feaaba..56bf3e60e8d884e5e86dcbc691bcb05eea026b96 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ stages: - build:dockerimage - rename:dockerimage - test + - publish_rpm before_script: - export CTA_BUILD_ID=${CI_PIPELINE_ID}git${CI_COMMIT_SHA:0:8} @@ -73,6 +74,15 @@ cta_tagged_rpm: tags: - docker +publish_tagged_rpm + stage: publish_rpm + image: gitlab-registry.cern.ch/linuxsupport/cc7-base + script: + - if [ -z "${CI_COMMIT_TAG}" ]; then echo "This is not a tagged commit, exiting"; exit 0; fi + - EOS_ACCOUNT_USERNAME=${DOCKER_LOGIN_USERNAME} EOS_ACCOUNT_PASSWORD=${DOCKER_LOGIN_PASSWORD} CI_OUTPUT_DIR=build_tagged_rpm/RPM/RPMS EOS_PATH=/eos/user/c/ctareg/www/test-repo/cta HOOK=/eos/user/c/ctareg/www/test-repo/update_repos.sh continuousintegration/ci_helpers/deploy-eos.sh + tags: + - docker + cta_valgrind: stage: test variables: diff --git a/continuousintegration/ci_helpers/deploy-eos.sh b/continuousintegration/ci_helpers/deploy-eos.sh new file mode 100755 index 0000000000000000000000000000000000000000..dbba2dc04e725744cca135d5b1c638a2286d5e62 --- /dev/null +++ b/continuousintegration/ci_helpers/deploy-eos.sh @@ -0,0 +1,120 @@ +#!/bin/bash + +# Derived from https://gitlab.cern.ch/ci-tools/ci-web-deployer +# Merges Dockerfile and deploy-eos.sh +# From commit 15c6bdccbee313df5601ce8df34fc4455fe92905 +# +# Copies provided artifacts and launch an additional hook + +# April 2016 Borja Aparicio +# Receives: +# Environment variables +# EOS_ACCOUNT_USERNAME +# EOS_ACCOUNT_PASSWORD +# CI_OUTPUT_DIR => default: public/ +# EOS_PATH +# HOOK + +# +# +# Produces: +# Uploads to $EOS_PATH in the EOS namespace the files found in CI_WEBSITE_DIR + +# Install what is not provided by the Dockerfile +yum install -y krb5-workstation rsync openssh-clients xrootd-client + +# SSH will be used to connect to LXPLUS and there check if the EOS folder exists +# SSH not needed anymore as we use xrootd +ssh="/usr/bin/ssh" +if [ ! -x $ssh ] +then + echo ERROR: $ssh not found + exit 1 +fi + +# Authenticate user via Kerberos +kinit="/usr/bin/kinit" +if [ ! -x $kinit ] +then + echo ERROR: $kinit not found + exit 1 +fi + +kdestroy="/usr/bin/kdestroy" +if [ ! -x $kdestroy ] +then + echo ERROR: $kdestroy not found + exit 1 +fi + +# XROOTD client to copy files to EOS +xrdcp="/usr/bin/xrdcp" +if [ ! -x $xrdcp ] +then + echo ERROR: $xrdcp not found + exit 1 +fi + +# Validate input +: "${EOS_ACCOUNT_USERNAME:?EOS_ACCOUNT_USERNAME not provided}" +: "${EOS_ACCOUNT_PASSWORD:?EOS_ACCOUNT_PASSWORD not provided}" +: "${EOS_PATH:?EOS_PATH not provided}" + +# Directory where the web site has been generated in the CI environment +# If not proviHOOK_ded by the user +if [ "X$CI_OUTPUT_DIR" == "X" ] +then + CI_OUTPUT_DIR="public/" +fi + +# Check the source directory exists +if [ ! -d $CI_OUTPUT_DIR ] +then + echo "ERROR: Source directory $CI_OUTPUT_DIR doesn't exist" + exit 1 +fi + +# Get credentials +echo "$EOS_ACCOUNT_PASSWORD" | $kinit $EOS_ACCOUNT_USERNAME@CERN.CH 2>&1 >/dev/null +if [ $? -ne 0 ] +then + echo Failed to get Krb5 credentials for $EOS_ACCOUNT_USERNAME + exit 1 +fi + +# Rely in xrootd to do the copy of files to EOS +$xrdcp --force --recursive $CI_OUTPUT_DIR/ root://eosuser.cern.ch/$EOS_PATH/ 2>&1 >/dev/null +if [ $? -ne 0 ] +then + echo ERROR: Failed to copy files to $EOS_PATH via xrdcp + exit 1 +fi + +# Run the provided HOOK +if [ -n "${HOOK}" ] +then + $ssh -o StrictHostKeyChecking=no -o GSSAPIAuthentication=yes -o GSSAPITrustDNS=yes -o GSSAPIDelegateCredentials=yes $EOS_ACCOUNT_USERNAME@lxplus.cern.ch $HOOK 2>&1 +if [ $? -ne 0 ] +then + echo "Something wrong happened when running hook $HOOK on lxplus:" + exit 1 +fi +fi +echo "HOOK executed successfully" + +# Rsync files with EOS +#$rsync --recursive --verbose -e "ssh -o StrictHostKeyChecking=no -o GSSAPIAuthentication=yes -o GSSAPITrustDNS=yes -o GSSAPIDelegateCredentials=yes" $CI_OUTPUT_DIR/ $EOS_ACCOUNT_USERNAME@lxplus.cern.ch:$EOS_PATH/ +#if [ $? -ne 0 ] +#then +# echo ERROR: Rsync to \"$EOS_PATH\" via lxplus.cern.ch, failed +# exit 1 +#fi + +# Destroy credentials +$kdestroy +if [ $? -ne 0 ] +then + echo Krb5 credentials for $DFS_ACCOUNT_USERNAME have not been cleared up +fi + +exit 0