Commit 17e6ce2e authored by Aleksandra Mnich's avatar Aleksandra Mnich
Browse files

Merge branch 'SIGMON-369_many_analysis_repos' into 'dev'

[SIGMON-369] lhc-sm-analysis deployment changed

See merge request !190
parents cb41ac9b 848ec2f7
Pipeline #4154651 failed with stages
in 16 minutes and 18 seconds
......@@ -223,8 +223,6 @@ deploy_lhcsmanalysis_eos:
- branches
image: gitlab-registry.cern.ch/ci-tools/ci-web-deployer
script:
- bash CI/commons_deployment_setup.sh
- bash CI/eos_setup.sh
- bash CI/deploy_analysis.sh
before_script: [ ]
after_script: [ ]
......
#!/bin/bash
# This script is triggered by CI to clone a chosen branch of lhc-sm-analysis and copy it's contents to the venv on EOS.
# The project lhc-sm-analysis consists of several packages with sigmon analysis.
# This script is triggered by CI to clone a chosen branch of the lhc-sm-analysis repositories and copy their contents to the venv on EOS.
# The lhc-sm-analysis group contains several repositories with sigmon analysis packages.
# Contents of each package are copied to be accessible under a path /eos/project/l/lhcsm/venv_${CI_COMMIT_BRANCH}/lhcsmapi/api/
# set ANALYSIS_BRANCH if not set
export ANALYSIS_BRANCH="${ANALYSIS_BRANCH:$CI_COMMIT_BRANCH}"
export ANALYSIS_BRANCH="${ANALYSIS_BRANCH:-$CI_COMMIT_BRANCH}"
# check if branch exists
git ls-remote --exit-code --heads https://:@gitlab.cern.ch:8443/LHCData/lhc-sm-analysis.git "${ANALYSIS_BRANCH}"
if [ "$?" == "2" ]; then
echo "Branch '${ANALYSIS_BRANCH}' not found in lhc-sm-analysis, using 'master' instead"
export ANALYSIS_BRANCH='master'
fi;
yum install git -y
yum install jq -y
git clone --single-branch --branch $ANALYSIS_BRANCH https://:@gitlab.cern.ch:8443/LHCData/lhc-sm-analysis.git
echo "${EOS_ACCOUNT_PASSWORD}" | kinit "${EOS_ACCOUNT_USERNAME}@CERN.CH"
analysis_dirs=($(find lhc-sm-analysis -maxdepth 1 -mindepth 1 -type d | grep -v 'CI' | grep -v 'git'))
REPOS=$(curl -s https://gitlab.cern.ch/api/v4/groups/152156 | jq -r ".projects[].http_url_to_repo")
EOS_PATH=/eos/project/l/lhcsm/venv_${CI_COMMIT_BRANCH}/lhcsmapi/api/
for REPO in ${REPOS}; do
rsync="/usr/bin/rsync"
if [ ! -x $rsync ]
then
echo ERROR: $rsync not found
exit 1
fi
# extract the name
DIR=($(echo $REPO | cut -d/ -f6 | cut -d. -f1))
# SSH will be used to connect to LXPLUS and there check if the EOS folder exists
ssh="/usr/bin/ssh"
if [ ! -x $ssh ]
then
echo ERROR: $ssh not found
exit 1
fi
# check if branch exists
git ls-remote --exit-code --heads "${REPO}" "${ANALYSIS_BRANCH}"
if [ "$?" == "2" ]; then
echo "Branch '${ANALYSIS_BRANCH}' not found in ${DIR}, using 'dev' instead"
export ANALYSIS_BRANCH='dev'
fi;
# Copy contents of each directory to EOS
git clone --single-branch --branch $ANALYSIS_BRANCH "${REPO}"
for dir in "${analysis_dirs[@]}"; do
$rsync -abvuz -e "ssh -o StrictHostKeyChecking=no -o GSSAPIAuthentication=yes -o GSSAPITrustDNS=yes -o GSSAPIDelegateCredentials=yes" $dir/lhcsmapi/api/analysis $EOS_ACCOUNT_USERNAME@lxplus.cern.ch:$EOS_PATH/
EOS_PATH=/eos/project/l/lhcsm/venv_${CI_COMMIT_BRANCH}/lhcsmapi/api/
rsync="/usr/bin/rsync"
if [ ! -x $rsync ]
then
echo ERROR: $rsync not found
exit 1
fi
# SSH will be used to connect to LXPLUS and there check if the EOS folder exists
ssh="/usr/bin/ssh"
if [ ! -x $ssh ]
then
echo ERROR: $ssh not found
exit 1
fi
# Copy contents to EOS
$rsync -abvuz -e "ssh -o StrictHostKeyChecking=no -o GSSAPIAuthentication=yes -o GSSAPITrustDNS=yes -o GSSAPIDelegateCredentials=yes" $DIR/lhcsmapi/api/analysis $EOS_ACCOUNT_USERNAME@lxplus.cern.ch:$EOS_PATH/
if [ $? -ne 0 ]
then
echo ERROR: Rsync to \"$EOS_PATH\" via lxplus.cern.ch, failed
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment