Skip to content
Snippets Groups Projects
Commit 3f4b1082 authored by Athanasios Karmas's avatar Athanasios Karmas
Browse files

First effort to copy files directly from gitlab runner to the OpenShift job pod

parent 85741d37
No related branches found
No related tags found
No related merge requests found
...@@ -9,21 +9,24 @@ variables: ...@@ -9,21 +9,24 @@ variables:
#SWIFT_FILE: ebrains-spack-builds${CI_PIPELINE_ID}.tar.gz #SWIFT_FILE: ebrains-spack-builds${CI_PIPELINE_ID}.tar.gz
SWIFT_FILE: ebrains-spack-builds.tar.gz SWIFT_FILE: ebrains-spack-builds.tar.gz
copy-files-to-swift: #copy-files-to-swift:
stage: upload # stage: upload
script: # script:
- 'curl -H "X-Auth-Token: ${OS_TOKEN}" -X DELETE ${OBJSTORE}ebrains-spack-builds.tar.gz > curl_log.txt' # - '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; # - 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 # - tar czf ${SWIFT_FILE} packages/ repo.yaml spack.yaml
- 'curl -H "X-Auth-Token: ${OS_TOKEN}" -i ${OBJSTORE} -X PUT -T ${SWIFT_FILE}' # - 'curl -H "X-Auth-Token: ${OS_TOKEN}" -i ${OBJSTORE} -X PUT -T ${SWIFT_FILE}'
tags: # tags:
- shell-runner # - shell-runner
deploy-build-environment: deploy-build-environment:
stage: deploy stage: deploy
needs: [copy-files-to-swift] #needs: [copy-files-to-swift]
before_script: before_script:
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN" - oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN"
- tar czf ${SWIFT_FILE} packages/ repo.yaml spack.yaml
- mkdir copy_folder
- mv ${SWIFT_FILE} copy_folder
script: script:
# create job description file # create job description file
- chmod a+x create_job.sh - chmod a+x create_job.sh
...@@ -33,15 +36,20 @@ deploy-build-environment: ...@@ -33,15 +36,20 @@ deploy-build-environment:
- oc project jupyterhub-int - oc project jupyterhub-int
# start the deploy job # start the deploy job
- oc create -f simplejob.yml - 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 ## 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' - 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 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 - 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 # when build job finishes get the logs
- oc logs jobs/simplejob${CI_PIPELINE_ID} | tee log.txt - oc logs jobs/simplejob${CI_PIPELINE_ID} | tee log.txt
# if spack install has failed, fail the pipeline # if spack install has failed, fail the pipeline
- if [ $(cat log.txt |grep "Error:"|wc -l) -gt 1 ]; then exit 1;fi; - 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 # 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: tags:
- shell-runner - shell-runner
......
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