This commit is contained in:
병준 박 2025-04-15 12:52:11 +00:00
parent ca8f4b339e
commit 4e7d7023df
11 changed files with 99 additions and 59 deletions

View File

@ -13,7 +13,7 @@ spec:
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
- name: base
type: string
default: ""
description: |
@ -27,17 +27,10 @@ spec:
script: |
#!/bin/bash
workingFolder="/workspace/shared/$(params.workingFolder)"
workingHomeFolder="/workspace/shared/__HOME__/$(params.workingFolder)"
if [ -d "${workingFolder}" ]; then
rm -rf "${workingFolder}"
echo "Deleted folder: ${workingFolder}"
base="/workspace/shared/$(params.base)"
if [ -d "${base}" ]; then
rm -rf "${base}"
echo "Deleted folder: ${base}"
else
echo "Folder not found: ${workingFolder}"
fi
if [ -d "${workingHomeFolder}" ]; then
rm -rf "${workingHomeFolder}"
echo "Deleted folder: ${workingHomeFolder}"
else
echo "Folder not found: ${workingHomeFolder}"
echo "Folder not found: ${base}"
fi

View File

@ -20,9 +20,15 @@ spec:
A prefix for the working folder name.
The final folder name will include this prefix, a timestamp, and a random string.
results:
- name: workingFolder
- 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:
@ -30,8 +36,10 @@ spec:
image: ubuntu
script: |
#!/bin/bash
workingFolder="$(params.workingFolderPrefix)-$(date +%s)-$(head /dev/urandom | tr -dc a-z0-9 | head -c 6)"
mkdir -p /workspace/shared/${workingFolder}
mkdir -p /workspace/shared/__HOME__/${workingFolder}
echo "Created folder: ${workingFolder}"
echo -n "${workingFolder}" > $(results.workingFolder.path)
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
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)

View File

@ -4,10 +4,15 @@ metadata:
name: docker-registry
spec:
params:
- name: subdirectory
- name: home
type: string
default: ""
description: Subdirectory within the repo where the source code is located
description: home directory
- name: workshop
type: string
default: ""
description: workshop within the repo where the source code is located
- name: imageName
type: string
@ -25,7 +30,7 @@ spec:
- name: context
type: string
default: .
description: Build context path (relative to subdirectory)
description: Build context path (relative to workshop)
workspaces:
- name: source
@ -40,7 +45,11 @@ spec:
steps:
- name: prepare-docker-auth
image: alpine:3.21.3
workingDir: /workspace/source/$(params.subdirectory)
workingDir: /workspace/source/$(params.workshop)
env:
- name: HOME
value: /workspace/shared/$(params.home)
script: |
#!/bin/sh
set -e
@ -55,10 +64,14 @@ spec:
- name: kaniko-build
image: gcr.io/kaniko-project/executor:v1.23.2
workingDir: $(workspaces.source.path)/$(params.subdirectory)
workingDir: $(workspaces.source.path)/$(params.workshop)
env:
- name: DOCKER_CONFIG
value: /tekton/home/.docker
env:
- name: HOME
value: /workspace/shared/$(params.home)
command:
- /kaniko/executor
args:
@ -68,8 +81,3 @@ spec:
- --skip-tls-verify
- --verbosity=info
- --reproducible
{{- if $(params.kanikoArgs) }}
{{- range $arg := splitList " " "$(params.kanikoArgs)" }}
- {{ $arg }}
{{- end }}
{{- end }}

View File

@ -45,10 +45,10 @@ spec:
default: "ca-bundle.crt"
description: file name of mounted crt using ssl-ca-directory workspace.
- name: subdirectory
- name: workshop
type: string
default: ""
description: Subdirectory inside the `output` Workspace to clone the repo into.
description: workshop inside the `output` Workspace to clone the repo into.
- name: sparseCheckoutDirectories
type: string
@ -158,7 +158,7 @@ spec:
cd /workspace/output
CLONE_DIR="$(params.subdirectory)"
CLONE_DIR="$(params.workshop)"
if [ -z "$CLONE_DIR" ]; then
CLONE_DIR="."
fi

View File

@ -4,9 +4,14 @@ metadata:
name: nx-nodejs-analysis
spec:
params:
- name: subdirectory
- name: home
type: string
description: Subdirectory within the repo where the source code is located
description: home directory
default: ""
- name: workshop
type: string
description: workshop within the repo where the source code is located
default: ""
- name: targetProject
@ -31,7 +36,10 @@ spec:
steps:
- name: lint-and-test
image: $(params.nodejsImageName)
workingDir: /workspace/source/$(params.subdirectory)
workingDir: /workspace/source/$(params.workshop)
env:
- name: HOME
value: /workspace/shared/$(params.home)
script: |
#!/usr/bin/env bash
set -e

View File

@ -4,10 +4,15 @@ metadata:
name: nx-nodejs-version
spec:
params:
- name: subdirectory
- name: home
type: string
description: Subdirectory within the repo where the source code is located
description: home directory
default: ""
- name: workshop
type: string
description: workshop within the repo where the source code is located
default: ""
- name: ref
type: string
description: Full Git ref string (e.g., refs/tags/v0.2.0)
@ -24,15 +29,14 @@ spec:
steps:
- name: verify-tag-version
image: $(params.nodejsImageName)
workingDir: /workspace/source
workingDir: /workspace/source/$(params.workshop)
env:
- name: HOME
value: /workspace/shared/$(params.home)
script: |
#!/usr/bin/env bash
set -e
if [ -n "$(params.subdirectory)" ]; then
cd $(params.subdirectory)
fi
echo "🔍 Extracting tag from Git ref..."
FULL_REF="$(params.ref)"
TAG_FROM_REF=$(basename "$FULL_REF") # → v0.2.0

View File

@ -4,10 +4,15 @@ metadata:
name: pybuild
spec:
params:
- name: subdirectory
- name: home
type: string
default: ""
description: Subdirectory within the repo where the source code is located
description: home directory
- name: workshop
type: string
default: ""
description: workshop within the repo where the source code is located
- name: pythonImageName
type: string
@ -25,10 +30,10 @@ spec:
steps:
- name: build-package
image: $(params.pythonImageName)
workingDir: /workspace/source/$(params.subdirectory)
workingDir: /workspace/source/$(params.workshop)
env:
- name: HOME
value: /workspace/shared/__HOME__/$(params.subdirectory)
value: /workspace/shared/$(params.home)
script: |
#!/usr/bin/env bash
set -e
@ -62,7 +67,7 @@ spec:
fi
echo "📂 Checking built artifacts..."
BUILD_PATH="/workspace/source/$(params.subdirectory)/dist"
BUILD_PATH="/workspace/source/$(params.workshop)/dist"
echo -n "$BUILD_PATH" > /tekton/results/build-artifact-path
if [ -d "$BUILD_PATH" ] && [ -n "$(ls -A "$BUILD_PATH")" ]; then

View File

@ -4,9 +4,14 @@ metadata:
name: pylint
spec:
params:
- name: subdirectory
- name: home
type: string
description: Subdirectory within the repo where the source code is located
description: home directory
default: ""
- name: workshop
type: string
description: workshop within the repo where the source code is located
default: ""
- name: pythonImageName
@ -37,10 +42,10 @@ spec:
steps:
- name: run-pylint
image: $(params.pythonImageName)
workingDir: /workspace/source/$(params.subdirectory)
workingDir: /workspace/source/$(params.workshop)
env:
- name: HOME
value: /workspace/shared/__HOME__/$(params.subdirectory)
value: /workspace/shared/$(params.home)
script: |
#!/usr/bin/env bash
set -e

View File

@ -4,6 +4,10 @@ metadata:
name: pypi
spec:
params:
- name: home
type: string
description: home directory
- name: build-artifact-path
type: string
description: Path to the built artifact directory from python-build
@ -28,7 +32,7 @@ spec:
workingDir: /workspace/source
env:
- name: HOME
value: /workspace/shared/__HOME__/$(params.subdirectory)
value: /workspace/shared/$(params.home)
script: |
#!/usr/bin/env bash
set -e

View File

@ -4,9 +4,14 @@ metadata:
name: pytest
spec:
params:
- name: subdirectory
- name: home
type: string
description: Subdirectory within the workspace where the tests are located
description: home directory
default: ""
- name: workshop
type: string
description: workshop within the workspace where the tests are located
default: ""
- name: pythonImageName
@ -21,10 +26,10 @@ spec:
steps:
- name: install-dependencies
image: $(params.pythonImageName)
workingDir: /workspace/source/$(params.subdirectory)
workingDir: /workspace/source/$(params.workshop)
env:
- name: HOME
value: /workspace/shared/__HOME__/$(params.subdirectory)
value: /workspace/shared/$(params.home)
script: |
#!/usr/bin/env bash
set -e

View File

@ -4,9 +4,9 @@ metadata:
name: secret-home
spec:
params:
- name: subdirectory
- name: home
type: string
description: Subdirectory within the repo where the source code is located
description: home directory
default: ""
- name: keys
@ -26,7 +26,7 @@ spec:
workingDir: /workspace/shared/$(params.subdirectory)
env:
- name: HOME
value: /workspace/shared/__HOME__/$(params.subdirectory)
value: /workspace/shared/$(params.home)
script: |
#!/usr/bin/env bash
set -e