-
Eleni Mathioulaki authored62f34857
.gitlab-ci.yml 13.78 KiB
stages:
- build
- deploy
- sync
# start an OpenShift Job that will build the Spack environment
.deploy-build-environment:
stage: deploy
script:
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN"
- tar czf ${SPACK_ENV_TAR_FILE} packages/ repo.yaml spack.yaml create_JupyterLab_kernel.sh
- mkdir copy_folder
- mv ${SPACK_ENV_TAR_FILE} copy_folder
# create job description file
- chmod a+x create_job.sh
- ./create_job.sh $INSTALLATION_ROOT $SPACKIFIED_ENV $OP $SPACK_ENV_TAR_FILE $CI_PIPELINE_ID $BUILD_ENV_DOCKER_IMAGE $LAB_KERNEL_PATH $OKD_CLUSTER_UID
- cat simplejob.yml
# select the project in openshift
- oc project $OC_PROJECT
# start the deploy job
- oc create -f simplejob.yml
## wait for job to finish https://stackoverflow.com/questions/5073453wait-for-kubernetes-job-to-complete-on-either-failure-success-using-command-line
- oc get job/simplejob${CI_PIPELINE_ID} -o=jsonpath='{.status}' -w && oc get job/simplejob${CI_PIPELINE_ID} -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo 'Failed'
# wait for job's pod to become available so as to copy from the gitlab runner to the OpenShift pod
# the necessary files that define the environment that spack needs to build
- while true; do x=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $3}');if [ $x == "Running" ]; then break; fi; sleep 10; done
- pod=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $1}')
- oc rsync copy_folder $pod:/opt/app-root/src
# when build job finishes get the logs
- while true; do sleep 300; x=$(oc get pods |grep $pod|awk '{ print $3}');if [ $x != "Running" ]; then break; fi; done
- oc logs jobs/simplejob${CI_PIPELINE_ID} | tee log.txt
# if spack install has failed, fail the pipeline
- if [ $(cat log.txt |grep "No module available for package"|wc -l) -gt 0 ]; then exit 1;fi;
# delete the job from OpenShift as we have the logs here
- oc delete job simplejob${CI_PIPELINE_ID} || true
tags:
- shell-runner
# Deploy in the lab-int environment the version of the tools to be
# tested before released to production (push pipeline)
# deploy on the dev environment of the okd dev cluster at CSCS
# runs on protected branches only as the token variable is protected
deploy-int-release-dev-cscs:
extends: .deploy-build-environment
variables:
OPENSHIFT_SERVER: $CSCS_OPENSHIFT_DEV_SERVER
OPENSHIFT_TOKEN: $CSCS_OPENSHIFT_DEV_TOKEN
INSTALLATION_ROOT: $CSCS_INSTALLATION_ROOT_DEV
SPACKIFIED_ENV: $CSCS_SPACKIFIED_ENV_DEV
OP: $CSCS_OPERATION_DEV
BUILD_ENV_DOCKER_IMAGE: $CSCS_BUILD_ENV_DOCKER_IMAGE_DEV
LAB_KERNEL_PATH: $CSCS_LAB_KERNEL_PATH_DEV
OKD_CLUSTER_UID: $CSCS_OKD_DEV_UID
#SPACK_ENV_TAR_FILE: ebrains-spack-builds${CI_PIPELINE_ID}.tar.gz
SPACK_ENV_TAR_FILE: ebrains-spack-builds.tar.gz
OC_PROJECT: jupyterhub-int
resource_group: shared-NFS-mount-dev-cscs
only:
- master
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
# Deploy the production release of tools (manual pipeline)
# deploy on the production environment of the okd prod cluster at CSCS
# runs on protected branches only as the token variable is protected
deploy-prod-release-prod-cscs:
extends: .deploy-build-environment
variables:
OPENSHIFT_SERVER: $CSCS_OPENSHIFT_PROD_SERVER