From 4c4f8c561764c1221646b79bdd91746993c2a7d7 Mon Sep 17 00:00:00 2001 From: Athanasios Karmas <karmas@athenarc.gr> Date: Fri, 23 Jul 2021 11:19:26 +0000 Subject: [PATCH] Propagate the logs of the OpenShift build job to the Gitlab runner so that pipeline watchers can see the build job logs --- .gitlab-ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fcb499cb..27cfc6f2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,13 +33,17 @@ deploy-build-environment: - cat simplejob.yml # select the project in openshift - oc project jupyterhub-int - # delete the job (if exist) - #- oc delete job simplejob || true # 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 -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo 'Failed' - - oc logs jobs/simplejob${CI_PIPELINE_ID} + #- oc get job/simplejob${CI_PIPELINE_ID} -o=jsonpath='{.status}' -w && oc get job/simplejob -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo 'Failed' + - while true; do x=$(oc get pods |grep simplejob${CI_PIPELINE_ID}|awk '{ print $3}');if [ $x != "Running" ]; then break; fi;done + # when build job finishes get the logs + - 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 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 -- GitLab