2025-04-15 12:52:11 +00:00

37 lines
1.1 KiB
YAML

apiVersion: tekton.dev/v1
kind: Task
metadata:
name: after-pipeline
annotations:
tekton.dev/pipelines.minVersion: "0.28.0"
tekton.dev/categories: "Cleanup"
tekton.dev/tags: "directory,workspace"
tekton.dev/displayName: "Cleanup Working Folder in Shared Workspace"
spec:
description: |
This task removes a previously created working folder in the shared workspace.
It accepts the folder name as a parameter. If the folder exists, it will be deleted.
If the folder name is not provided or the folder does not exist, the task will exit gracefully.
params:
- name: base
type: string
default: ""
description: |
The name of the folder in the shared workspace to delete.
If empty, no cleanup action will be performed.
workspaces:
- name: shared
steps:
- name: cleanup-folder
image: ubuntu
script: |
#!/bin/bash
base="/workspace/shared/$(params.base)"
if [ -d "${base}" ]; then
rm -rf "${base}"
echo "Deleted folder: ${base}"
else
echo "Folder not found: ${base}"
fi