diff --git a/tasks/git-clone-checkout/task.yaml b/tasks/git-clone-checkout/task.yaml index 6e6fec3..d202eec 100644 --- a/tasks/git-clone-checkout/task.yaml +++ b/tasks/git-clone-checkout/task.yaml @@ -14,6 +14,12 @@ spec: default: "" description: context directory + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) + - name: url type: string description: The Git repository URL to clone. @@ -122,7 +128,7 @@ spec: cd /workspace/base/$(params.context) - CLONE_DIR="source" + CLONE_DIR="$(params.source)" if [ -z "$CLONE_DIR" ]; then CLONE_DIR="." fi diff --git a/tasks/git-commit-push/task.yaml b/tasks/git-commit-push/task.yaml new file mode 100644 index 0000000..1ec3e13 --- /dev/null +++ b/tasks/git-commit-push/task.yaml @@ -0,0 +1,59 @@ +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: git-commit-push +spec: + description: | + This task clones a Git repository and checks out a specified branch if it exists. + Supports SSH, basic-auth, custom CA certs, sparse checkout, submodules, shallow clone, and proxy settings. + The commit SHA, committer date, and fetched URL are exposed as Task results. + + params: + - name: context + type: string + default: "" + description: context directory + + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) + + - name: remote + type: string + description: Specifies the name of the remote repository (e.g., origin). + default: "origin" + + - name: branch + type: string + description: Specifies the name of the local branch to push. + default: "main" + + + - name: commitMessage + type: string + default: "chore: commpit projects" + description: commit message + + + workspaces: + - name: base + description: The workspace where the repository will be cloned. + + steps: + - name: clone + image: alpine/git:latest + workingDir: /workspace/base/$(params.context)/$(params.source) + env: + - name: HOME + value: /workspace/base/$(params.context)/home + script: | + #!/bin/sh + set -eu + + git add . + git commit -m "$(params.commitMessage)" || exit 0 + git push origin HEAD:main + + diff --git a/tasks/git-replace/task.yaml b/tasks/git-replace/task.yaml deleted file mode 100644 index e959185..0000000 --- a/tasks/git-replace/task.yaml +++ /dev/null @@ -1,90 +0,0 @@ -apiVersion: tekton.dev/v1 -kind: Task -metadata: - name: git-replace-multi - annotations: - tekton.dev/pipelines.minVersion: "0.19.0" - tekton.dev/categories: GitOps - tekton.dev/tags: git, devops - tekton.dev/displayName: "replace multiple files/dirs in git repository" - tekton.dev/platforms: "linux/amd64" -spec: - description: | - Replaces multiple files or directories in a Git repository, committing and pushing the changes. - - params: - - name: repositoryUrl - type: string - description: Source repository URL - - - name: branch - type: string - default: main - description: Git branch to push to - - - name: targetPaths - type: array - description: List of target paths in the repo (file or directory, e.g. dir/ or file) - - - name: sourcePaths - type: array - description: List of source paths in the workspace (file or directory, e.g. dir/ or file) - - - name: commitMessage - type: string - default: "chore(gitops): replace multiple files or dirs" - description: Commit message - - workspaces: - - name: base - - name: tmp - - steps: - - name: clone-repository - image: alpine/git:latest - script: | - #!/bin/sh - set -e - REPO_URL="$(params.repositoryUrl)" - BRANCH="$(params.branch)" - WORKSPACE_PATH="$(workspaces.tmp.path)" - git clone --branch "${BRANCH}" "${REPO_URL}" "${WORKSPACE_PATH}/repo" - cd "${WORKSPACE_PATH}/repo" - - - name: sync-files - image: alpine:3.18 - script: | - #!/bin/sh - set -e - TARGET_PATHS=($(params.targetPaths[*])) - SOURCE_PATHS=($(params.sourcePaths[*])) - BASE_PATH="$(workspaces.base.path)/source" - REPO_PATH="$(workspaces.tmp.path)/repo" - COUNT=${#TARGET_PATHS[@]} - if [ $COUNT -ne ${#SOURCE_PATHS[@]} ]; then - echo "targetPaths와 sourcePaths의 길이가 다릅니다." - exit 1 - fi - for i in $(seq 0 $(($COUNT - 1))); do - TARGET="${REPO_PATH}/${TARGET_PATHS[$i]}" - SOURCE="${BASE_PATH}/${SOURCE_PATHS[$i]}" - [ -e "${TARGET}" ] && rm -rf "${TARGET}" || true - mkdir -p $(dirname "${TARGET}") - cp -r "${SOURCE}" "${TARGET}" - done - - - name: commit-and-push - image: alpine/git:latest - script: | - #!/bin/sh - set -e - cd "$(workspaces.tmp.path)/repo" - git config --global user.name "tekton-bot" - git config --global user.email "tekton@example.com" - git add . - git commit -m "$(params.commitMessage)" || exit 0 - git push origin HEAD:"$(params.branch)" - - volumes: - - name: tmp - emptyDir: {} diff --git a/tasks/nodejs-nx-analysis/task.yaml b/tasks/nodejs-nx-analysis/task.yaml index 664b3ed..7072279 100644 --- a/tasks/nodejs-nx-analysis/task.yaml +++ b/tasks/nodejs-nx-analysis/task.yaml @@ -9,6 +9,12 @@ spec: description: context directory default: "" + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) + - name: workspaceName type: string description: Nx workspace name to lint and test @@ -35,7 +41,7 @@ spec: steps: - name: lint-and-test image: $(params.nodejsImageName) - workingDir: /workspace/base/$(params.context)/source/$(params.workspaceName) + workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName) env: - name: HOME value: /workspace/base/$(params.context)/home diff --git a/tasks/nodejs-nx-version/task.yaml b/tasks/nodejs-nx-version/task.yaml index a1152dd..bfcf6aa 100644 --- a/tasks/nodejs-nx-version/task.yaml +++ b/tasks/nodejs-nx-version/task.yaml @@ -8,6 +8,13 @@ spec: type: string description: context directory default: "" + + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) + - name: workspaceName type: string description: Nx workspace project name to lint and test @@ -28,7 +35,7 @@ spec: steps: - name: verify-tag-version image: $(params.nodejsImageName) - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) env: - name: HOME value: /workspace/base/$(params.context)/home diff --git a/tasks/openapi-generate/task.yaml b/tasks/openapi-generate/task.yaml index 5ec5b1c..674b20c 100644 --- a/tasks/openapi-generate/task.yaml +++ b/tasks/openapi-generate/task.yaml @@ -8,6 +8,16 @@ spec: type: string description: context directory default: "" + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) + - name: output + type: string + default: "output" + description: | + output directory (sub directory of context) - name: packageNamePrefix description: Rust crate name prefix @@ -42,12 +52,10 @@ spec: steps: - name: generate-code image: openapitools/openapi-generator-cli:v7.4.0 - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) env: - name: HOME value: /workspace/base/$(params.context)/home - # command: - # - openapi-generator-cli args: - generate - -i @@ -55,8 +63,8 @@ spec: - -g - $(params.generator) - -o - - "/workspace/base/$(params.context)/output/$(params.packageNamePrefix)$(params.specDomain)-$(params.version)-$(params.generator)" - - --additional-properties=packageName=$(params.packageNamePrefix)$(params.context) + - "/workspace/base/$(params.context)/$(params.output)" + - --additional-properties=packageName=$(params.packageNamePrefix)$(params.specDomain) - --additional-properties=packageVersion=$(params.version) - --additional-properties=publish=true - --additional-properties=disableValidator=false @@ -66,5 +74,5 @@ spec: image: alpine:latest script: | #!/bin/sh - OUTPUT="/workspace/base/$(params.context)/output/$(params.packageNamePrefix)$(params.specDomain)-$(params.version)-$(params.generator)" + OUTPUT="/workspace/base/$(params.context)/$(params.output)" echo -n "${OUTPUT}" > $(results.output.path) \ No newline at end of file diff --git a/tasks/openapi-version/task.yaml b/tasks/openapi-version/task.yaml index 3e108c7..ab806a3 100644 --- a/tasks/openapi-version/task.yaml +++ b/tasks/openapi-version/task.yaml @@ -8,6 +8,13 @@ spec: type: string description: context directory default: "" + + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) + - name: ref type: string description: Full Git ref string (e.g., refs/tags/v0.2.0) @@ -22,7 +29,7 @@ spec: steps: - name: verify-version image: mikefarah/yq:4.24.2 - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) env: - name: HOME value: /workspace/base/$(params.context)/home diff --git a/tasks/pybuild/task.yaml b/tasks/pybuild/task.yaml index 97cbb88..f64bcb2 100644 --- a/tasks/pybuild/task.yaml +++ b/tasks/pybuild/task.yaml @@ -8,6 +8,11 @@ spec: type: string default: "" description: home directory + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) - name: pythonImageName type: string @@ -25,7 +30,7 @@ spec: steps: - name: build-package image: $(params.pythonImageName) - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) env: - name: HOME value: /workspace/base/$(params.context)/home @@ -62,7 +67,7 @@ spec: fi echo "📂 Checking built artifacts..." - BUILD_PATH="/workspace/base/$(params.context)/source/dist" + BUILD_PATH="/workspace/base/$(params.context)/$(params.source)/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 e891aa4..cb1fe64 100644 --- a/tasks/pylint/task.yaml +++ b/tasks/pylint/task.yaml @@ -8,6 +8,11 @@ spec: type: string description: context directory default: "" + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) - name: pythonImageName type: string @@ -37,7 +42,7 @@ spec: steps: - name: run-pylint image: $(params.pythonImageName) - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) env: - name: HOME value: /workspace/base/$(params.context)/home diff --git a/tasks/pytest/task.yaml b/tasks/pytest/task.yaml index d22cea5..0ba6a8b 100644 --- a/tasks/pytest/task.yaml +++ b/tasks/pytest/task.yaml @@ -8,6 +8,11 @@ spec: type: string description: context directory default: "" + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) - name: pythonImageName type: string @@ -21,7 +26,7 @@ spec: steps: - name: install-dependencies image: $(params.pythonImageName) - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) env: - name: HOME value: /workspace/base/$(params.context)/home diff --git a/tasks/pyversion/task.yaml b/tasks/pyversion/task.yaml index 6def176..7f38a12 100644 --- a/tasks/pyversion/task.yaml +++ b/tasks/pyversion/task.yaml @@ -8,6 +8,11 @@ spec: type: string description: context directory default: "" + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) - name: ref type: string @@ -29,7 +34,7 @@ spec: steps: - name: verify-tag image: $(params.pythonImageName) - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) script: | #!/usr/bin/env bash set -e diff --git a/tasks/rust-nx-merge/task.yaml b/tasks/rust-nx-merge/task.yaml index c8357b5..6220140 100644 --- a/tasks/rust-nx-merge/task.yaml +++ b/tasks/rust-nx-merge/task.yaml @@ -17,6 +17,11 @@ spec: type: string description: context directory default: "" + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) - name: version type: string @@ -42,7 +47,7 @@ spec: steps: - name: install-deps image: node:18-alpine - workingDir: /workspace/base/$(params.context)/source/$(params.workspaceName) + workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName) env: - name: HOME value: /workspace/base/$(params.context)/home @@ -57,7 +62,7 @@ spec: - name: import-projects image: node:18-alpine - workingDir: /workspace/base/$(params.context)/source/$(params.workspaceName) + workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName) env: - name: HOME value: /workspace/base/$(params.context)/home @@ -107,7 +112,7 @@ spec: - name: git-commit image: alpine/git:latest - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) env: - name: HOME value: /workspace/base/$(params.context)/home diff --git a/tasks/secret-home/task.yaml b/tasks/secret-home/task.yaml index cc4425d..3aad41f 100644 --- a/tasks/secret-home/task.yaml +++ b/tasks/secret-home/task.yaml @@ -8,6 +8,11 @@ spec: type: string description: context directory default: "" + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) - name: keys type: string @@ -23,7 +28,7 @@ spec: steps: - name: extract image: python:3.11-slim - workingDir: /workspace/base/$(params.context)/source + workingDir: /workspace/base/$(params.context)/$(params.source) env: - name: HOME value: /workspace/base/$(params.context)/home diff --git a/tasks/sonarqube-analysis/taks.yaml b/tasks/sonarqube-analysis/taks.yaml index bcc39d0..0f9a383 100644 --- a/tasks/sonarqube-analysis/taks.yaml +++ b/tasks/sonarqube-analysis/taks.yaml @@ -8,6 +8,11 @@ spec: type: string default: "" description: "소스코드가 있는 하위 디렉토리 (없을 경우 '')" + - name: source + type: string + default: "source" + description: | + source directory (sub directory of context) - name: sonarqubeUrl type: string