From a5bfccc3144d839d0ec427792406e8ead80e43f9 Mon Sep 17 00:00:00 2001 From: Athanasios Karmas <karmas@athenarc.gr> Date: Mon, 26 Jul 2021 11:12:55 +0000 Subject: [PATCH] Code cleanup and final touches for sending spack yaml files and packages to the Openshift build job through the Gitlab runner instead of using SWIFT as the intermediate --- .gitlab-ci.yml | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 78e39ae0..83e8a5d0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,31 +6,20 @@ variables: OPENSHIFT_SERVER: https://okd-dev.hbp.eu BUILD_ENV: test-build OP: update - #SWIFT_FILE: ebrains-spack-builds${CI_PIPELINE_ID}.tar.gz - SWIFT_FILE: ebrains-spack-builds.tar.gz - -#copy-files-to-swift: -# stage: upload -# script: -# - 'curl -H "X-Auth-Token: ${OS_TOKEN}" -X DELETE ${OBJSTORE}ebrains-spack-builds.tar.gz > curl_log.txt' -# - if [ $(cat curl_log.txt | grep "Unauthorized" |wc -l) -gt 0 ]; then echo "You need to refresh OpenStack token"; exit 1;fi; -# - tar czf ${SWIFT_FILE} packages/ repo.yaml spack.yaml -# - 'curl -H "X-Auth-Token: ${OS_TOKEN}" -i ${OBJSTORE} -X PUT -T ${SWIFT_FILE}' -# tags: -# - shell-runner + #SPACK_ENV_TAR_FILE: ebrains-spack-builds${CI_PIPELINE_ID}.tar.gz + SPACK_ENV_TAR_FILE: ebrains-spack-builds.tar.gz deploy-build-environment: stage: deploy - #needs: [copy-files-to-swift] before_script: - oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN" - - tar czf ${SWIFT_FILE} packages/ repo.yaml spack.yaml + - tar czf ${SPACK_ENV_TAR_FILE} packages/ repo.yaml spack.yaml - mkdir copy_folder - - mv ${SWIFT_FILE} copy_folder + - mv ${SPACK_ENV_TAR_FILE} copy_folder script: # create job description file - chmod a+x create_job.sh - - ./create_job.sh $BUILD_ENV $OP $SWIFT_FILE $CI_PIPELINE_ID + - ./create_job.sh $BUILD_ENV $OP $SPACK_ENV_TAR_FILE $CI_PIPELINE_ID - cat simplejob.yml # select the project in openshift - oc project jupyterhub-int @@ -43,13 +32,13 @@ deploy-build-environment: - while true; do x=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $3}');if [ $x == "Running" ]; then break; fi; sleep 1; done - pod=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $1}') - oc rsync copy_folder $pod:/opt/app-root/src - - while true; do x=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $3}');if [ $x != "Running" ]; then break; fi; sleep 10; done # when build job finishes get the logs + - while true; do x=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $3}');if [ $x != "Running" ]; then break; fi; sleep 10; done - oc logs jobs/simplejob${CI_PIPELINE_ID} | tee log.txt # if spack install has failed, fail the pipeline - if [ $(cat log.txt |grep "Error:"|wc -l) -gt 1 ]; then exit 1;fi; # delete the job from OpenShift as we have the logs here - #- oc delete job simplejob${CI_PIPELINE_ID} || true + - oc delete job simplejob${CI_PIPELINE_ID} || true tags: - shell-runner -- GitLab