This commit is contained in:
2024-04-23 12:48:06 +02:00
parent db3ab4fd13
commit 1e0a70dc70
2 changed files with 30 additions and 15 deletions

View File

@@ -10,7 +10,6 @@ const sources=[
#{url: "https://github.com/tektoncd/catalog/raw/main/task/check-make/0.1/check-make.yaml", name: "check-make.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/check-make/0.1/check-make.yaml", name: "check-make.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/docker-build/0.1/docker-build.yaml", name: "docker-build.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/docker-build/0.1/docker-build.yaml", name: "docker-build.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/generate-build-id/0.1/generate-build-id.yaml", name: "generate-build-id.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/generate-build-id/0.1/generate-build-id.yaml", name: "generate-build-id.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/git-clone/0.9/git-clone.yaml", name: "git-clone.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/gitea-set-status/0.1/gitea-set-status.yaml", name: "gitea-set-status.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/gitea-set-status/0.1/gitea-set-status.yaml", name: "gitea-set-status.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/hadolint/0.1/hadolint.yaml", name: "hadolint.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/hadolint/0.1/hadolint.yaml", name: "hadolint.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/hugo/0.1/hugo.yaml", name: "hugo.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/hugo/0.1/hugo.yaml", name: "hugo.yaml"},

View File

@@ -45,6 +45,10 @@ spec:
A workspace containing CA certificates, this will be used by Git to A workspace containing CA certificates, this will be used by Git to
verify the peer with when fetching or pushing over HTTPS. verify the peer with when fetching or pushing over HTTPS.
params: params:
- name: toolbox-image
default: sebt3/basic-toolbox-image:1.30.0
description: The name of the toolbox image
type: string
- name: url - name: url
description: Repository URL to clone from. description: Repository URL to clone from.
type: string type: string
@@ -99,10 +103,6 @@ spec:
description: Log the commands that are executed during `git-clone`'s operation. description: Log the commands that are executed during `git-clone`'s operation.
type: string type: string
default: "true" default: "true"
- name: gitInitImage
description: The image providing the git-init binary that this Task runs.
type: string
default: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.40.2"
- name: userHome - name: userHome
description: | description: |
Absolute path to the user's home directory. Absolute path to the user's home directory.
@@ -117,7 +117,7 @@ spec:
description: The epoch timestamp of the commit that was fetched by this Task. description: The epoch timestamp of the commit that was fetched by this Task.
steps: steps:
- name: clone - name: clone
image: "$(params.gitInitImage)" image: $(params.toolbox-image)
env: env:
- name: HOME - name: HOME
value: "$(params.userHome)" value: "$(params.userHome)"
@@ -220,16 +220,32 @@ spec:
test -z "${PARAM_HTTPS_PROXY}" || export HTTPS_PROXY="${PARAM_HTTPS_PROXY}" test -z "${PARAM_HTTPS_PROXY}" || export HTTPS_PROXY="${PARAM_HTTPS_PROXY}"
test -z "${PARAM_NO_PROXY}" || export NO_PROXY="${PARAM_NO_PROXY}" test -z "${PARAM_NO_PROXY}" || export NO_PROXY="${PARAM_NO_PROXY}"
FETCH_CMD=""
if [ $PARAM_DEPTH -gt 0 ];then
FETCH_CMD+="--depth $PARAM_DEPTH"
fi
git config --global --add safe.directory "${WORKSPACE_OUTPUT_PATH}" git config --global --add safe.directory "${WORKSPACE_OUTPUT_PATH}"
/ko-app/git-init \ git config --global --add http.sslVerify "${PARAM_SSL_VERIFY}"
-url="${PARAM_URL}" \ cd "${CHECKOUT_DIR}"
-revision="${PARAM_REVISION}" \ git init
-refspec="${PARAM_REFSPEC}" \ if [ "${PARAM_SPARSE_CHECKOUT_DIRECTORIES}" != "" ];then
-path="${CHECKOUT_DIR}" \ git config --global --add core.sparsecheckout true
-sslVerify="${PARAM_SSL_VERIFY}" \ mkdir -p .git/info/
-submodules="${PARAM_SUBMODULES}" \ echo "${PARAM_SPARSE_CHECKOUT_DIRECTORIES}"|sed 's/,/\n/'>.git/info/sparse-checkout
-depth="${PARAM_DEPTH}" \ chmod 644 .git/info/sparse-checkout
-sparseCheckoutDirectories="${PARAM_SPARSE_CHECKOUT_DIRECTORIES}" fi
git remote add origin "${PARAM_URL}"
git fetch "--recurse-submodules=${PARAM_SUBMODULES}" $FETCH_CMD origin --update-head-ok --force
git reset --hard "${PARAM_REVISION}"
#/ko-app/git-init \
# -url="${PARAM_URL}" \
# -revision="${PARAM_REVISION}" \
# -refspec="${PARAM_REFSPEC}" \
# -path="${CHECKOUT_DIR}" \
# -sslVerify="${PARAM_SSL_VERIFY}" \
# -submodules="${PARAM_SUBMODULES}" \
# -depth="${PARAM_DEPTH}" \
# -sparseCheckoutDirectories="${PARAM_SPARSE_CHECKOUT_DIRECTORIES}"
cd "${CHECKOUT_DIR}" cd "${CHECKOUT_DIR}"
RESULT_SHA="$(git rev-parse HEAD)" RESULT_SHA="$(git rev-parse HEAD)"
EXIT_CODE="$?" EXIT_CODE="$?"