Skip to content
Snippets Groups Projects

Add helm charts for cluster tasks and run tasks with a job

Merged Dimitra Chatzichrysou requested to merge run-task-with-a-job into master
Files
11
@@ -10,9 +10,11 @@ spec:
- name: namespace
type: string
description: The namespace of the drupal site
workspaces:
- name: job
steps:
- name: clear-cache
image: image-registry.openshift-image-registry.svc:5000/openshift/cli:latest
image: {{ .Values.openshiftCli.image }}
command:
- /bin/sh
- '-c'
@@ -20,6 +22,13 @@ spec:
- |-
echo "--------------------------- Clear cache ---------------------------"
echo "Drupal site name: $(params.drupalSite)"
deploymentPod=$(oc get pods -n $(params.namespace) -l drupalSite=$(params.drupalSite) -l app=drupal -o custom-columns=POD:.metadata.name --no-headers)
echo "Deployment pod: $deploymentPod"
oc exec $deploymentPod -c php-fpm drush cr
export TASK=clear-cache
export DRUPALSITE=$(params.drupalSite)
export NAMESPACE=$(params.namespace)
export SERVING_POD_IMAGE=$(oc get -n $(params.namespace) drupalsite/$(params.drupalSite) -o=jsonpath='{.status.servingPodImage}')
envsubst < $(workspaces.job.path)/{{ .Values.jobTemplateFile }} | oc create -n $(params.namespace) -f -
oc wait --for=condition=complete job/$TASK-$(params.drupalSite)
jobStatus=$(oc get job/$TASK-$(params.drupalSite) -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo "Failed")
echo "Job status: $jobStatus"
echo "Job logs:"
oc logs job/$TASK-$DRUPALSITE -n $(params.namespace)
Loading