From 404eeeea024c4bdf1347bb07794e1be13eced9c2 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 21 Jun 2026 23:03:05 -0400 Subject: [PATCH] Introduce a git-clone task. The official git-clone task her permission issues when cloning a private repo, so I'm introducing my own. --- task/git-clone/0.1/git-clone.yaml | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 task/git-clone/0.1/git-clone.yaml diff --git a/task/git-clone/0.1/git-clone.yaml b/task/git-clone/0.1/git-clone.yaml new file mode 100644 index 0000000..9d8cbff --- /dev/null +++ b/task/git-clone/0.1/git-clone.yaml @@ -0,0 +1,60 @@ +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: git-clone + labels: + app.kubernetes.io/version: "0.1" + annotations: + tekton.dev/categories: SCM + tekton.dev/pipelines.minVersion: "1.12.1" + tekton.dev/tags: scm + tekton.dev/displayName: "Clone a git repository." + tekton.dev/platforms: "linux/amd64" +spec: + description: >- + This task will clone a git repository. + workspaces: + - name: output + mountPath: /output + readOnly: false + params: + - name: url + type: string + description: The repository url to clone. + - name: revision + type: string + description: The revision to clone. + - name: IMAGE + type: string + description: Docker image to use for performing the clone. + default: "alpine/git:v2.54.0" + results: + - name: commit + type: string + description: The commit hash that was cloned. + - name: url + type: string + description: The URL to the git repo. + - name: committer-date + type: string + description: The time of the git commit in unix timestamp format. + steps: + - name: fetch-repository-step + image: $(params.IMAGE) + workingDir: "$(workspaces.output.path)" + script: | + #!/usr/bin/env sh + set -euo pipefail + export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=accept-new" + git init --initial-branch=main + git remote add origin $(params.url) + git fetch -v origin $(params.revision) + git checkout FETCH_HEAD + + git rev-parse HEAD > $(results.commit.path) + echo "$(params.url)" > $(results.url.path) + echo -n "$(git log -1 --pretty=%ct)" > $(results.committer-date.path) + # securityContext: + # runAsNonRoot: true + # runAsUser: 1000 + # runAsGroup: 1000