47 lines
1.8 KiB
YAML
47 lines
1.8 KiB
YAML
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: before-pipeline
|
|
annotations:
|
|
tekton.dev/pipelines.minVersion: "0.28.0"
|
|
tekton.dev/categories: "Preparation"
|
|
tekton.dev/tags: "directory,workspace"
|
|
tekton.dev/displayName: "Create Working Folder in Shared Workspace"
|
|
spec:
|
|
description: |
|
|
This task generates a unique working folder inside the provided shared workspace.
|
|
The folder name is a combination of the given prefix, a timestamp, and a random string.
|
|
The result can be used as a scoped working directory for subsequent tasks in a pipeline.
|
|
params:
|
|
- name: workingFolderPrefix
|
|
type: string
|
|
default: "pipeline-run"
|
|
description: |
|
|
A prefix for the working folder name.
|
|
The final folder name will include this prefix, a timestamp, and a random string.
|
|
results:
|
|
- name: base
|
|
description: |
|
|
The unique folder name created in the shared workspace.
|
|
- name: home
|
|
description: |
|
|
The unique home folder name created in the shared workspace.
|
|
- name: workshop
|
|
description: |
|
|
The unique working folder name created in the shared workspace.
|
|
workspaces:
|
|
- name: shared
|
|
steps:
|
|
- name: create-folder
|
|
image: ubuntu
|
|
script: |
|
|
#!/bin/bash
|
|
uniqueFolder="$(params.workingFolderPrefix)-$(date +%s)-$(head /dev/urandom | tr -dc a-z0-9 | head -c 6)"
|
|
mkdir -p /workspace/shared/${uniqueFolder}/workshop
|
|
mkdir -p /workspace/shared/${uniqueFolder}/home
|
|
chmod -R a+rwX /workspace/shared/${uniqueFolder}
|
|
echo "Created folder: ${uniqueFolder}/{workshop | home}"
|
|
echo -n "${uniqueFolder}" > $(results.base.path)
|
|
echo -n "${uniqueFolder}/workshop" > $(results.workshop.path)
|
|
echo -n "${uniqueFolder}/home" > $(results.home.path)
|