Skip to content

Commit 0ad67b6

Browse files
committed
chore: Update git-clone task location
* Updated the `git-clone` task source URL in all `.tekton` configuration files to the new repository location at `tektoncd-catalog/git-clone`. * Migrated documentation links to point to the new `tektoncd-catalog/git-clone` repository. * Pinned `git-clone` task usage to a specific commit hash for improved stability. - Vendored the git-clone Tekton StepAction into the repository. - Updated all Tekton pipelines to use the local version of the StepAction. - This change removes the dependency on the external tektoncd-catalog repository. - Using a local copy improves the reliability and stability of the CI pipelines. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
1 parent c6fdb38 commit 0ad67b6

File tree

9 files changed

+232
-9
lines changed

9 files changed

+232
-9
lines changed

.tekton/doc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
resolver: http
3434
params:
3535
- name: url
36-
value: https://raw.githubusercontent.com/tektoncd/catalog/main/stepaction/git-clone/0.1/git-clone.yaml
36+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/stepactions/git-clone.yaml
3737
params:
3838
- name: output-path
3939
value: $(workspaces.source.path)

.tekton/generate-coverage-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
resolver: http
3434
params:
3535
- name: url
36-
value: https://raw.githubusercontent.com/tektoncd/catalog/main/stepaction/git-clone/0.1/git-clone.yaml
36+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/stepactions/git-clone.yaml
3737
params:
3838
- name: output-path
3939
value: $(workspaces.source.path)

.tekton/go.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
resolver: http
3131
params:
3232
- name: url
33-
value: https://raw.githubusercontent.com/tektoncd/catalog/main/stepaction/git-clone/0.1/git-clone.yaml
33+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/stepactions/git-clone.yaml
3434
params:
3535
- name: output-path
3636
value: $(workspaces.source.path)

.tekton/linter.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spec:
2929
resolver: http
3030
params:
3131
- name: url
32-
value: https://raw.githubusercontent.com/tektoncd/catalog/main/stepaction/git-clone/0.1/git-clone.yaml
32+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/stepactions/git-clone.yaml
3333
params:
3434
- name: output-path
3535
value: $(workspaces.source.path)

.tekton/stepactions/git-clone.yaml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: StepAction
3+
metadata:
4+
name: git-clone
5+
labels:
6+
app.kubernetes.io/version: "0.1"
7+
annotations:
8+
tekton.dev/pipelines.minVersion: "0.54.0"
9+
tekton.dev/categories: Git
10+
tekton.dev/tags: git
11+
tekton.dev/displayName: "git clone"
12+
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
13+
spec:
14+
params:
15+
- name: output-path
16+
description: The git repo will be cloned onto this path
17+
- name: ssh-directory-path
18+
description: |
19+
A .ssh directory with private key, known_hosts, config, etc. Copied to
20+
the user's home before git commands are executed. Used to authenticate
21+
with the git remote when performing the clone. We recommend providing this
22+
path from a workspace that is bound by a Secret over other volume types.
23+
default: "no-path"
24+
- name: basic-auth-path
25+
description: |
26+
A directory path containing a .gitconfig and .git-credentials file. These
27+
will be copied to the user's home before any git commands are run. Any
28+
other files in this directory are ignored. It is strongly recommended
29+
to use ssh-directory over basic-auth whenever possible and to bind a
30+
Secret to the Workspace providing this path over other volume types.
31+
default: "no-path"
32+
- name: ssl-ca-directory-path
33+
description: |
34+
A directory containing CA certificates, this will be used by Git to
35+
verify the peer with when fetching or pushing over HTTPS.
36+
default: "no-path"
37+
- name: url
38+
description: Repository URL to clone from.
39+
type: string
40+
- name: revision
41+
description: Revision to checkout. (branch, tag, sha, ref, etc...)
42+
type: string
43+
default: ""
44+
- name: refspec
45+
description: Refspec to fetch before checking out revision.
46+
default: ""
47+
- name: submodules
48+
description: Initialize and fetch git submodules.
49+
type: string
50+
default: "true"
51+
- name: depth
52+
description: Perform a shallow clone, fetching only the most recent N commits.
53+
type: string
54+
default: "1"
55+
- name: sslVerify
56+
description: Set the `http.sslVerify` global git config. Setting this to `false` is not advised unless you are sure that you trust your git remote.
57+
type: string
58+
default: "true"
59+
- name: crtFileName
60+
description: file name of mounted crt using ssl-ca-directory workspace. default value is ca-bundle.crt.
61+
type: string
62+
default: "ca-bundle.crt"
63+
- name: subdirectory
64+
description: Subdirectory inside the `output` Workspace to clone the repo into.
65+
type: string
66+
default: ""
67+
- name: sparseCheckoutDirectories
68+
description: Define the directory patterns to match or exclude when performing a sparse checkout.
69+
type: string
70+
default: ""
71+
- name: deleteExisting
72+
description: Clean out the contents of the destination directory if it already exists before cloning.
73+
type: string
74+
default: "true"
75+
- name: httpProxy
76+
description: HTTP proxy server for non-SSL requests.
77+
type: string
78+
default: ""
79+
- name: httpsProxy
80+
description: HTTPS proxy server for SSL requests.
81+
type: string
82+
default: ""
83+
- name: noProxy
84+
description: Opt out of proxying HTTP/HTTPS requests.
85+
type: string
86+
default: ""
87+
- name: verbose
88+
description: Log the commands that are executed during `git-clone`'s operation.
89+
type: string
90+
default: "true"
91+
- name: gitInitImage
92+
description: The image providing the git-init binary that this StepAction runs.
93+
type: string
94+
default: "ghcr.io/tektoncd/github.com/tektoncd/pipeline/cmd/git-init:v0.40.2"
95+
- name: userHome
96+
description: |
97+
Absolute path to the user's home directory.
98+
type: string
99+
default: "/home/git"
100+
results:
101+
- name: commit
102+
description: The precise commit SHA that was fetched by this StepAction.
103+
- name: url
104+
description: The precise URL that was fetched by this StepAction.
105+
- name: committer-date
106+
description: The epoch timestamp of the commit that was fetched by this StepAction.
107+
image: "$(params.gitInitImage)"
108+
env:
109+
- name: HOME
110+
value: "$(params.userHome)"
111+
- name: PARAM_URL
112+
value: $(params.url)
113+
- name: PARAM_REVISION
114+
value: $(params.revision)
115+
- name: PARAM_REFSPEC
116+
value: $(params.refspec)
117+
- name: PARAM_SUBMODULES
118+
value: $(params.submodules)
119+
- name: PARAM_DEPTH
120+
value: $(params.depth)
121+
- name: PARAM_SSL_VERIFY
122+
value: $(params.sslVerify)
123+
- name: PARAM_CRT_FILENAME
124+
value: $(params.crtFileName)
125+
- name: PARAM_SUBDIRECTORY
126+
value: $(params.subdirectory)
127+
- name: PARAM_DELETE_EXISTING
128+
value: $(params.deleteExisting)
129+
- name: PARAM_HTTP_PROXY
130+
value: $(params.httpProxy)
131+
- name: PARAM_HTTPS_PROXY
132+
value: $(params.httpsProxy)
133+
- name: PARAM_NO_PROXY
134+
value: $(params.noProxy)
135+
- name: PARAM_VERBOSE
136+
value: $(params.verbose)
137+
- name: PARAM_SPARSE_CHECKOUT_DIRECTORIES
138+
value: $(params.sparseCheckoutDirectories)
139+
- name: PARAM_USER_HOME
140+
value: $(params.userHome)
141+
- name: PARAM_OUTPUT_PATH
142+
value: $(params.output-path)
143+
- name: PARAM_SSH_DIRECTORY_PATH
144+
value: $(params.ssh-directory-path)
145+
- name: PARAM_BASIC_AUTH_DIRECTORY_PATH
146+
value: $(params.basic-auth-path)
147+
- name: PARAM_SSL_CA_DIRECTORY_PATH
148+
value: $(params.ssl-ca-directory-path)
149+
securityContext:
150+
runAsNonRoot: true
151+
runAsUser: 65532
152+
script: |
153+
#!/usr/bin/env sh
154+
set -eu
155+
156+
if [ "${PARAM_VERBOSE}" = "true" ] ; then
157+
set -x
158+
fi
159+
160+
if [ "${PARAM_BASIC_AUTH_DIRECTORY_PATH}" != "no-path" ] ; then
161+
cp "${PARAM_BASIC_AUTH_DIRECTORY_PATH}/.git-credentials" "${PARAM_USER_HOME}/.git-credentials"
162+
cp "${PARAM_BASIC_AUTH_DIRECTORY_PATH}/.gitconfig" "${PARAM_USER_HOME}/.gitconfig"
163+
chmod 400 "${PARAM_USER_HOME}/.git-credentials"
164+
chmod 400 "${PARAM_USER_HOME}/.gitconfig"
165+
fi
166+
167+
if [ "${PARAM_SSH_DIRECTORY_PATH}" != "no-path" ] ; then
168+
cp -R "${PARAM_SSH_DIRECTORY_PATH}" "${PARAM_USER_HOME}"/.ssh
169+
chmod 700 "${PARAM_USER_HOME}"/.ssh
170+
chmod -R 400 "${PARAM_USER_HOME}"/.ssh/*
171+
fi
172+
173+
if [ "${PARAM_SSL_CA_DIRECTORY_PATH}" != "no-path" ] ; then
174+
export GIT_SSL_CAPATH="${PARAM_SSL_CA_DIRECTORY_PATH}"
175+
if [ "${PARAM_CRT_FILENAME}" != "" ] ; then
176+
export GIT_SSL_CAINFO="${PARAM_SSL_CA_DIRECTORY_PATH}/${PARAM_CRT_FILENAME}"
177+
fi
178+
fi
179+
CHECKOUT_DIR="${PARAM_OUTPUT_PATH}/${PARAM_SUBDIRECTORY}"
180+
181+
cleandir() {
182+
# Delete any existing contents of the repo directory if it exists.
183+
#
184+
# We don't just "rm -rf ${CHECKOUT_DIR}" because ${CHECKOUT_DIR} might be "/"
185+
# or the root of a mounted volume.
186+
if [ -d "${CHECKOUT_DIR}" ] ; then
187+
# Delete non-hidden files and directories
188+
rm -rf "${CHECKOUT_DIR:?}"/*
189+
# Delete files and directories starting with . but excluding ..
190+
rm -rf "${CHECKOUT_DIR}"/.[!.]*
191+
# Delete files and directories starting with .. plus any other character
192+
rm -rf "${CHECKOUT_DIR}"/..?*
193+
fi
194+
}
195+
196+
if [ "${PARAM_DELETE_EXISTING}" = "true" ] ; then
197+
cleandir || true
198+
fi
199+
200+
test -z "${PARAM_HTTP_PROXY}" || export HTTP_PROXY="${PARAM_HTTP_PROXY}"
201+
test -z "${PARAM_HTTPS_PROXY}" || export HTTPS_PROXY="${PARAM_HTTPS_PROXY}"
202+
test -z "${PARAM_NO_PROXY}" || export NO_PROXY="${PARAM_NO_PROXY}"
203+
204+
git config --global --add safe.directory "${PARAM_OUTPUT_PATH}"
205+
/ko-app/git-init \
206+
-url="${PARAM_URL}" \
207+
-revision="${PARAM_REVISION}" \
208+
-refspec="${PARAM_REFSPEC}" \
209+
-path="${CHECKOUT_DIR}" \
210+
-sslVerify="${PARAM_SSL_VERIFY}" \
211+
-submodules="${PARAM_SUBMODULES}" \
212+
-depth="${PARAM_DEPTH}" \
213+
-sparseCheckoutDirectories="${PARAM_SPARSE_CHECKOUT_DIRECTORIES}"
214+
cd "${CHECKOUT_DIR}"
215+
RESULT_SHA="$(git rev-parse HEAD)"
216+
EXIT_CODE="$?"
217+
if [ "${EXIT_CODE}" != 0 ] ; then
218+
exit "${EXIT_CODE}"
219+
fi
220+
RESULT_COMMITTER_DATE="$(git log -1 --pretty=%ct)"
221+
printf "%s" "${RESULT_COMMITTER_DATE}" > "$(step.results.committer-date.path)"
222+
printf "%s" "${RESULT_SHA}" > "$(step.results.commit.path)"
223+
printf "%s" "${PARAM_URL}" > "$(step.results.url.path)"

docs/content/docs/guide/authoringprs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ weight: 3
2222
- Inside your pipeline, you need to be able to check out the commit as
2323
received from the webhook by checking out the repository from that ref. Most of the time
2424
you want to reuse the
25-
[git-clone](https://github.com/tektoncd/catalog/blob/main/task/git-clone/)
26-
task from the [tektoncd/catalog](https://github.com/tektoncd/catalog).
25+
[git-clone](https://github.com/tektoncd-catalog/git-clone/tree/main/task/git-clone)
26+
task from the [tektoncd/catalog](https://github.com/tektoncd-catalog/git-clone/tree/main/task/git-clone).
2727

2828
- To be able to specify parameters of your commit and URL, Pipelines-as-Code
2929
gives you some “dynamic” variables that are defined according to the execution

docs/content/docs/guide/privaterepo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ depending on your requirements.
4040
## Using the generated token in your PipelineRun
4141

4242
The git-clone task documentation, which is available at
43-
<https://github.com/tektoncd/catalog/blob/main/task/git-clone/0.4/README.md>,
43+
<https://github.com/tektoncd-catalog/git-clone/tree/main/task/git-clone>,
4444
states that the secret needs to be referred to as a workspace named
4545
"basic-auth" inside your PipelineRun so that it can be passed to
4646
the `git-clone` task.

docs/content/docs/guide/resolver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pipelinesascode.tekton.dev/task: "git-clone"
8484
```
8585
8686
The syntax above installs the
87-
[git-clone](https://github.com/tektoncd/catalog/tree/main/task/git-clone) task
87+
[git-clone](https://github.com/tektoncd-catalog/git-clone/tree/main/task/git-clone) task
8888
from the [tekton hub](https://hub.tekton.dev) repository querying for the latest
8989
version with the tekton hub API.
9090

test/testdata/pipelinerun-stepactions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
resolver: http
1919
params:
2020
- name: url
21-
value: https://raw.githubusercontent.com/tektoncd/catalog/main/stepaction/git-clone/0.1/git-clone.yaml
21+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/stepactions/git-clone.yaml
2222
params:
2323
- name: output-path
2424
value: "/tmp/output"

0 commit comments

Comments
 (0)