You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
= Step action definitions provided with {pipelines-shortname}
8
+
9
+
{pipelines-shortname} provides standard `StepAction` definitions that you can use in your tasks. Use the cluster resolver to reference these definitions.
8
10
9
-
{pipelines-shortname} provides a standard `StepAction` definition that you can use in your tasks. Use the cluster resolver to reference this definition.
10
11
11
12
[discrete]
12
13
[id="op-stepaction-git-clone_{context}"]
@@ -23,7 +24,7 @@ kind: Task
23
24
metadata:
24
25
name: clone-repo-anon
25
26
spec:
26
-
# ...
27
+
# ...
27
28
steps:
28
29
- name: clone-repo-step
29
30
ref:
@@ -75,3 +76,173 @@ spec:
75
76
|`URL` |`string` |The URL of the repository that was cloned.
76
77
|`COMMITTER_DATE` |`string` |The epoch timestamp of the commit that is at the HEAD of the current branch in the cloned Git repository.
77
78
|===
79
+
80
+
81
+
[discrete]
82
+
[id="op-stepaction-cache-{context}"]
83
+
== cache-upload and cache-fetch
84
+
85
+
:FeatureName: Using the `cache-upload` and `cache-fetch` step actions
86
+
include::snippets/technology-preview.adoc[]
87
+
88
+
Use the `cache-upload` and `cache-fetch` step actions to preserve the cache directory where a build process keeps its dependencies, storing it in an Amazon Simple Storage Service (S3) bucket, Google Cloud Services (GCS) bucket, or an Open Container Initiative (OCI) repository.
89
+
90
+
When you use the `cache-upload` step action, the step action calculates a hash based on certain files in your build. You must provide a regular expression to select these files. The `cache-upload` step action stores an image that contains the content of your cache directory, indexed with the hash.
91
+
92
+
When you use the `cache-fetch` step action, the step action calculates the same hash. Then it checks whether a cached image for this hash is already available. If the image is available, the step action populates your cache directory with the cached content. If the image is not available, the directory remains as it was.
93
+
94
+
After using the `cache-fetch` step action, you can run the build process. If the cache is successfully fetched, it includes the dependencies that the build process downloaded previously. If the cache was not fetched, the build process downloads dependencies through its normal procedure.
95
+
96
+
The result of `cache-fetch` indicates whether a cached image was fetched. The subsequent `cache-upload` step action can use the result and skip uploading a new cache image if the cache for the current hash was already available.
97
+
98
+
The following example task retrieves the source from a repository, fetches the cache (if available), runs a Maven build, and then, if the cache was not fetched, uploads the new cached image of the build directory.
99
+
100
+
.Example usage of the `cache-fetch` and `cache-upload` step actions in a task
echo "Cache size is $(du -sh $(workspaces.source.path)/cache)"
185
+
- name: cache-upload
186
+
ref:
187
+
resolver: cluster
188
+
params:
189
+
- name: name
190
+
value: cache-upload
191
+
- name: namespace
192
+
value: openshift-pipelines
193
+
- name: kind
194
+
value: stepaction
195
+
params:
196
+
- name: patterns
197
+
value: $(params.cachePatterns)
198
+
- name: target
199
+
value: oci://$(params.registry):{{hash}}
200
+
- name: cachePath
201
+
value: $(workspaces.source.path)/cache
202
+
- name: workingdir
203
+
value: $(workspaces.source.path)/repo
204
+
- name: force-cache-upload
205
+
value: $(params.force-cache-upload)
206
+
----
207
+
208
+
.Supported parameters for the `cache-fetch` step action
209
+
[cols="1,2,1,1",options="header"]
210
+
|===
211
+
| Parameter | Description | Type | Default value
212
+
|`patterns` |Regular expression for selecting files to compute the hash. For example, for a Go project, you can use `go.mod` files to compute the cache, and then the value of this parameter is `pass:[**]/go.sum` (where `pass:[**]` accounts for subdirectories of any depth). | `array` |
213
+
|`source` |Source URI for fetching the cache; use `{{hash}}` to specify the cache hash. The supported types are `oci` (example: `oci://quay.io/example-user/go-cache:{{hash}}`) and `s3` (example: `s3://example-bucket/{{hash}}`) | `string` |
214
+
|`cachePath` |Path for extracting the cache content. Normally this path is in a workspace. | `string` |
215
+
|`workingDir` |Path where the files for calculating the hash are located. | `string` |
216
+
|`insecure` |If `"true"`, use insecure mode for fetching the cache. | `string` |`"false"`
217
+
|`googleCredentialsPath` |The path where Google credentials are located. Ignored if empty. | `string` |
218
+
|`awsConfigFile` |Path to the AWS configuration file. Ignored if empty. | `string` |
219
+
|`awsCredentialFile` |Path to the AWS credentials file. Ignored if empty. | `string` |
220
+
|`blobQueryParams` |Blob query parameters for configuring S3, GCS, or Azure. Use these optional parameters for additional features such as S3 acceleration, FIPS, or path-style addressing. | `string` |
221
+
|===
222
+
223
+
.Results that the `cache-fetch` step action returns
224
+
[cols="1,1,2",options="header"]
225
+
|===
226
+
| Result | Type | Description
227
+
|`fetched` |`string` |`"true"` if the step has fetched the cache or `"false"` if the step has not fetched the cache.
228
+
|===
229
+
230
+
231
+
.Supported parameters for the `cache-upload` step action
232
+
[cols="1,2,1,1",options="header"]
233
+
|===
234
+
| Parameter | Description | Type | Default value
235
+
|`patterns` |Regular expression for selecting files to compute the hash. For example, for a Go project, you can use `go.mod` files to compute the cache, and then the value of this parameter is `pass:[**]/go.sum` (where `pass:[**]` accounts for subdirectories of any depth). | `array` |
236
+
|`target` |Target URI for uploading the cache; use `{{hash}}` to specify the cache hash. The supported types are `oci` (example: `oci://quay.io/example-user/go-cache:{{hash}}`) and `s3` (example: `s3://example-bucket/{{hash}}`) | `string` |
237
+
|`cachePath` |Path for cache content, which the step packs into the image. Normally this path is in a workspace. | `string` |
238
+
|`workingDir` |Path where the files for calculating the hash are located. | `string` |
239
+
|`insecure` |If `"true"`, use insecure mode for uploading the cache. | `string` |`"false"`
240
+
|`fetched` |If `"true"`, the cache for this hash was already fetched. | `string` |`"false"`
241
+
|`force-cache-upload` |If `"true"`, the step uploads the cache even if it was fetched previously. | `string` |`"false"`
242
+
|`googleCredentialsPath` |The path where Google credentials are located. Ignored if empty. | `string` |
243
+
|`awsConfigFile` |Path to the AWS configuration file. Ignored if empty. | `string` |
244
+
|`awsCredentialFile` |Path to the AWS credentials file. Ignored if empty. | `string` |
245
+
|`blobQueryParams` |Blob query parameters for configuring S3, GCS, or Azure. Use these optional parameters for additional features such as S3 acceleration, FIPS, or path-style addressing. | `string` |
246
+
|===
247
+
248
+
The `cache-upload` step action returns no results.
0 commit comments