apiVersion: tekton.dev/v1 kind: Task metadata: name: before-pipeline spec: params: - name: pvcEnable type: string default: "false" description: | Whether to create a PersistentVolumeClaim (PVC). Set to "true" to create a PVC. Set to "false" to skip creation. - name: pvcSize type: string default: "1Gi" description: | The requested size of the PVC (e.g., "1Gi", "5Gi"). results: - name: pvcName description: | The name of the created PVC. If pvcEnable is false, this will be an empty string. steps: - name: maybe-create-pvc image: bitnami/kubectl:latest script: | #!/bin/sh set -e echo "pvcEnable: $(params.pvcEnable)" if [ "$(params.pvcEnable)" = "true" ]; then # Generate a random PVC name RAND=$(head /dev/urandom | tr -dc a-z0-9 | head -c 6) PVC_NAME="before-pvc-${RAND}" echo "Creating PVC: ${PVC_NAME}" # Apply PVC manifest cat < $(results.pvcName.path) echo "PVC creation complete: ${PVC_NAME}" else echo "PVC creation skipped (pvcEnable=false)" echo -n "" > $(results.pvcName.path) fi