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: workingFolder 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 workingFolder="/workspace/shared/$(params.workingFolder)" if [ -d "${workingFolder}" ]; then rm -rf "${workingFolder}" echo "Deleted folder: ${workingFolder}" else echo "Folder not found: ${workingFolder}" fi