From 4e7d7023df5eee5955e11f8769789272db923f32 Mon Sep 17 00:00:00 2001 From: BAK BYEONG JUN Date: Tue, 15 Apr 2025 12:52:11 +0000 Subject: [PATCH] init --- tasks/after-pipeline/task.yaml | 19 ++++++------------- tasks/before-pipeline/task.yaml | 20 ++++++++++++++------ tasks/docker-registry/task.yaml | 28 ++++++++++++++++++---------- tasks/git-clone-checkout/task.yaml | 6 +++--- tasks/nodejs-nx-analysis/task.yaml | 14 +++++++++++--- tasks/nodejs-nx-version/task.yaml | 18 +++++++++++------- tasks/pybuild/task.yaml | 15 ++++++++++----- tasks/pylint/task.yaml | 13 +++++++++---- tasks/pypi/task.yaml | 6 +++++- tasks/pytest/task.yaml | 13 +++++++++---- tasks/secret-home/task.yaml | 6 +++--- 11 files changed, 99 insertions(+), 59 deletions(-) diff --git a/tasks/after-pipeline/task.yaml b/tasks/after-pipeline/task.yaml index 30b7a06..d3cd71c 100644 --- a/tasks/after-pipeline/task.yaml +++ b/tasks/after-pipeline/task.yaml @@ -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 diff --git a/tasks/before-pipeline/task.yaml b/tasks/before-pipeline/task.yaml index b20a9a0..24aa206 100644 --- a/tasks/before-pipeline/task.yaml +++ b/tasks/before-pipeline/task.yaml @@ -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) diff --git a/tasks/docker-registry/task.yaml b/tasks/docker-registry/task.yaml index 0cceb0b..0a1d9a3 100644 --- a/tasks/docker-registry/task.yaml +++ b/tasks/docker-registry/task.yaml @@ -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 }} diff --git a/tasks/git-clone-checkout/task.yaml b/tasks/git-clone-checkout/task.yaml index cc1f675..fdeb240 100644 --- a/tasks/git-clone-checkout/task.yaml +++ b/tasks/git-clone-checkout/task.yaml @@ -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 diff --git a/tasks/nodejs-nx-analysis/task.yaml b/tasks/nodejs-nx-analysis/task.yaml index 3f89285..494feb6 100644 --- a/tasks/nodejs-nx-analysis/task.yaml +++ b/tasks/nodejs-nx-analysis/task.yaml @@ -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 diff --git a/tasks/nodejs-nx-version/task.yaml b/tasks/nodejs-nx-version/task.yaml index 8773de4..f13e6a1 100644 --- a/tasks/nodejs-nx-version/task.yaml +++ b/tasks/nodejs-nx-version/task.yaml @@ -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 diff --git a/tasks/pybuild/task.yaml b/tasks/pybuild/task.yaml index ace4e2f..7121773 100644 --- a/tasks/pybuild/task.yaml +++ b/tasks/pybuild/task.yaml @@ -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 diff --git a/tasks/pylint/task.yaml b/tasks/pylint/task.yaml index 86fbef7..b398a62 100644 --- a/tasks/pylint/task.yaml +++ b/tasks/pylint/task.yaml @@ -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 diff --git a/tasks/pypi/task.yaml b/tasks/pypi/task.yaml index 46b9b64..1d27b1a 100644 --- a/tasks/pypi/task.yaml +++ b/tasks/pypi/task.yaml @@ -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 diff --git a/tasks/pytest/task.yaml b/tasks/pytest/task.yaml index a1414bd..9344ee7 100644 --- a/tasks/pytest/task.yaml +++ b/tasks/pytest/task.yaml @@ -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 diff --git a/tasks/secret-home/task.yaml b/tasks/secret-home/task.yaml index b8c70b1..0f770de 100644 --- a/tasks/secret-home/task.yaml +++ b/tasks/secret-home/task.yaml @@ -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