36 lines
1.1 KiB
YAML
36 lines
1.1 KiB
YAML
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: after-pipeline
|
|
spec:
|
|
params:
|
|
- name: persistence4delete
|
|
type: object
|
|
properties:
|
|
volumeName:
|
|
type: string
|
|
namespace:
|
|
type: string
|
|
default:
|
|
volumeName: ""
|
|
namespace: ""
|
|
|
|
steps:
|
|
- name: delete-pvc-if-exists
|
|
image: bitnami/kubectl:latest
|
|
script: |
|
|
#!/usr/bin/env bash
|
|
|
|
if [ -n "$(params.persistence4delete.volumeName)" ]; then
|
|
if kubectl get pvc $(params.persistence4delete.volumeName) -n $(params.persistence4delete.namespace) >/dev/null 2>&1; then
|
|
echo "PVC $(params.persistence4delete.volumeName) exists, deleting..."
|
|
kubectl delete pvc $(params.persistence4delete.volumeName) -n $(params.persistence4delete.namespace)
|
|
echo "PVC $(params.persistence4delete.volumeName) deleted."
|
|
else
|
|
echo "PVC $(params.persistence4delete.volumeName) does not exist, skipping deletion."
|
|
fi
|
|
else
|
|
echo "No persistence4delete.volumeName provided, nothing to delete."
|
|
fi
|
|
|