Skip to content

Commit 4f2cf21

Browse files
authored
Merge pull request #79033 from mramendi/RHDEVDOCS-6104
RHDEVDOCS 6104 support for StepActions
2 parents 28e163f + 6bdbd4b commit 4f2cf21

11 files changed

+373
-55
lines changed

_attributes/common-attributes.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
:pipelines-title: Red Hat OpenShift Pipelines
1414
:pipelines-shortname: OpenShift Pipelines
15-
:pipelines-ver: pipelines-1.15
16-
:pipelines-version-number: 1.15
15+
:pipelines-ver: pipelines-1.16
16+
:pipelines-version-number: 1.16
1717
:tekton-chains: Tekton Chains
1818
:tekton-results: Tekton Results
1919
:tekton-hub: Tekton Hub

about/understanding-openshift-pipelines.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ include::modules/op-about-pipelinerun.adoc[leveloffset=+2]
4545

4646
//About workspace
4747
include::modules/op-about-workspace.adoc[leveloffset=+2]
48+
49+
//About stepactions
50+
include::modules/op-about-stepactions.adoc[leveloffset=+2]
51+
[role="_additional-resources"]
52+
.Additional resources
53+
54+
* xref:../create/remote-pipelines-tasks-resolvers.adoc#remote-pipelines-tasks-resolvers[Specifying remote pipelines, tasks, and step actions using resolvers]
55+
4856
//About triggers
4957
include::modules/op-about-triggers.adoc[leveloffset=+2]
5058

create/remote-pipelines-tasks-resolvers.adoc

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
:_mod-docs-content-type: ASSEMBLY
22
include::_attributes/common-attributes.adoc[]
33
[id="remote-pipelines-tasks-resolvers"]
4-
= Specifying remote pipelines and tasks using resolvers
4+
= Specifying remote pipelines, tasks, and step actions using resolvers
55
:context: remote-pipelines-tasks-resolvers
66

77
toc::[]
@@ -10,22 +10,30 @@ Pipelines and tasks are reusable blocks for your CI/CD processes. You can reuse
1010

1111
In a pipeline run resource, you can specify a pipeline from an existing source. In a pipeline resource or a task run resource, you can specify a task from an existing source.
1212

13-
In these cases, the _resolvers_ in {pipelines-title} retrieve the pipeline or task definition from the specified source at run time.
13+
Step actions, defined in `StepAction` custom resources (CRs), are reusable actions that a single step within a task completes. When specifying a step, you can reference a `StepAction` definition from an existing source.
14+
15+
In these cases, the _resolvers_ in {pipelines-title} retrieve the pipeline, task, or `StepAction` definition from the specified source at run time.
1416

1517
The following resolvers are available in a default installaton of {pipelines-title}:
1618

17-
Hub resolver:: Retrieves a task or pipeline from the Pipelines Catalog available on {artifact-hub} or {tekton-hub}.
18-
Bundles resolver:: Retrieves a task or pipeline from a Tekton bundle, which is an OCI image available from any OCI repository, such as an OpenShift container repository.
19+
Hub resolver:: Retrieves a task, pipeline, or `StepAction` definition from the Pipelines Catalog available on {artifact-hub} or {tekton-hub}.
20+
Bundles resolver:: Retrieves a task, pipeline, or `StepAction` definition from a Tekton bundle, which is an OCI image available from any OCI repository, such as an OpenShift container repository.
21+
Git resolver:: Retrieves a task, pipeline, or `StepAction` definition from a Git repository. You must specify the repository, the branch, and the path.
22+
HTTP resolver:: Retrieves a task, pipeline, or `StepAction` definition from a remote HTTP or HTTPS URL. You must specify the URL for authentication.
1923
Cluster resolver:: Retrieves a task or pipeline that is already created on the same {OCP} cluster in a specific namespace.
20-
Git resolver:: Retrieves a task or pipeline binding from a Git repository. You must specify the repository, the branch, and the path.
21-
HTTP resolver:: Retrieves a task or pipeline from a remote HTTP or HTTPS URL. You must specify the URL for authentication.
24+
+
25+
[NOTE]
26+
====
27+
In {pipelines-shortname} version {pipelines-version-number}, the cluster resolver does not support retrieving `StepAction` definitions.
28+
====
2229

2330
An {pipelines-shortname} installation includes a set of standard tasks that you can use in your pipelines. These tasks are located in the {pipelines-shortname} installation namespace, which is normally the `openshift-pipelines` namespace. You can use the cluster resolver to access the tasks.
2431

25-
[id="resolver-hub_{context}"]
26-
== Specifying a remote pipeline or task from a Tekton catalog
32+
{pipelines-shortname} also provides a standard `StepAction` definition. You can use the HTTP resolver to access this definition.
2733

28-
You can use the hub resolver to specify a remote pipeline or task that is defined either in a public Tekton catalog of link:https://artifacthub.io/[{artifact-hub}] or in an instance of {tekton-hub}.
34+
[id="resolver-hub_{context}"]
35+
== Specifying a remote pipeline, task, or step action from a Tekton catalog
36+
You can use the hub resolver to specify a remote pipeline, task, or `StepAction` definition that is defined either in a public Tekton catalog of link:https://artifacthub.io/[{artifact-hub}] or in an instance of {tekton-hub}.
2937

3038
[IMPORTANT]
3139
====
@@ -36,50 +44,52 @@ include::modules/op-resolver-hub-config.adoc[leveloffset=+2]
3644
include::modules/op-resolver-hub.adoc[leveloffset=+2]
3745

3846
[id="resolver-bundles_{context}"]
39-
== Specifying a remote pipeline or task from a Tekton bundle
47+
== Specifying a remote pipeline, task, or step action from a Tekton bundle
4048

41-
You can use the bundles resolver to specify a remote pipeline or task from a Tekton bundle. A Tekton bundle is an OCI image available from any OCI repository, such as an OpenShift container repository.
49+
You can use the bundles resolver to specify a remote pipeline, task, or `StepAction` definition from a Tekton bundle. A Tekton bundle is an OCI image available from any OCI repository, such as an OpenShift container repository.
4250

4351
include::modules/op-resolver-bundle-config.adoc[leveloffset=+2]
4452
include::modules/op-resolver-bundle.adoc[leveloffset=+2]
4553

46-
[id="resolver-cluster_{context}"]
47-
== Specifying a pipeline or task from the same cluster
48-
49-
You can use the cluster resolver to specify a pipeline or task that is defined in a namespace on the {OCP} cluster where {pipelines-title} is running.
50-
51-
In particular, you can use the cluster resolver to access tasks that {pipelines-shortname} provides in its installation namespace, which is normally the `openshift-pipelines` namespace.
52-
53-
include::modules/op-resolver-cluster-config.adoc[leveloffset=+2]
54-
include::modules/op-resolver-cluster.adoc[leveloffset=+2]
55-
56-
include::modules/op-resolver-cluster-tasks-ref.adoc[leveloffset=+1]
57-
5854
[id="resolver-git-anon_{context}"]
59-
== Specifying a remote pipeline or task with anonymous Git cloning
55+
== Specifying a remote pipeline, task, or step action with anonymous Git cloning
6056

61-
You can use the Git resolver to access a remote pipeline or task from a Git repository. The repository must include a YAML file that defines the pipeline or task. For anonymous access, you can clone repositories with the resolver without needing authentication credentials.
57+
You can use the Git resolver to access a remote pipeline, task, or `StepAction` definition from a Git repository. The repository must include a YAML file that defines the pipeline or task. For anonymous access, you can clone repositories with the resolver without needing authentication credentials.
6258

6359
include::modules/op-resolver-git-config-anon.adoc[leveloffset=+2]
6460
include::modules/op-resolver-git-anon.adoc[leveloffset=+2]
6561

6662
[id="resolver-git-scm_{context}"]
67-
== Specifying a remote pipeline or task with an authenticated API
63+
== Specifying a remote pipeline, task, or step action with an authenticated Git API
6864

69-
You can specify a remote pipeline or task from a Git repository by using the Git resolver. The repository must contain a YAML file that defines the pipeline or task. You can securely access repositories by using an authenticated API, which supports user authentication.
65+
You can specify a remote pipeline, task, or `StepAction` definition from a Git repository by using the Git resolver. The repository must contain a YAML file that defines the pipeline or task. You can securely access repositories by using an authenticated API, which supports user authentication.
7066

7167
include::modules/op-resolver-git-config-scm.adoc[leveloffset=+2]
7268
include::modules/op-resolver-git-scm.adoc[leveloffset=+2]
7369
include::modules/op-resolver-git-override-scm.adoc[leveloffset=+2]
7470

7571
[id="resolver-http_{context}"]
76-
== Specifying a remote pipeline or task by using the HTTP resolver
72+
== Specifying a remote pipeline, task, or step action by using the HTTP resolver
7773

78-
You can specify a remote pipeline or task from an HTTP or HTTPS URL by using the HTTP resolver. The URL must point to a YAML file that defines the pipeline or task.
74+
You can specify a remote pipeline, task, or `StepAction` definition from an HTTP or HTTPS URL by using the HTTP resolver. The URL must point to a YAML file that defines the pipeline, task, or step action.
7975

8076
include::modules/op-resolver-http-config.adoc[leveloffset=+2]
8177
include::modules/op-resolver-http.adoc[leveloffset=+2]
8278

79+
[id="resolver-cluster_{context}"]
80+
== Specifying a pipeline or task from the same cluster
81+
82+
You can use the cluster resolver to specify a pipeline or task that is defined in a namespace on the {OCP} cluster where {pipelines-title} is running.
83+
84+
In particular, you can use the cluster resolver to access tasks that {pipelines-shortname} provides in its installation namespace, which is normally the `openshift-pipelines` namespace.
85+
86+
include::modules/op-resolver-cluster-config.adoc[leveloffset=+2]
87+
include::modules/op-resolver-cluster.adoc[leveloffset=+2]
88+
89+
include::modules/op-resolver-cluster-tasks-ref.adoc[leveloffset=+1]
90+
91+
include::modules/op-resolver-stepactions-ref.adoc[leveloffset=+1]
92+
8393

8494
[role="_additional-resources"]
8595
[id="additional-resources_{context}"]

modules/op-about-stepactions.adoc

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// This module is included in the following assemblies:
2+
// * about/understanding-openshift-pipelines.adoc
3+
4+
:_mod-docs-content-type: CONCEPT
5+
[id="about-stepactions_{context}"]
6+
= Step actions
7+
8+
A step is a part of a task. If you define a step in a task, you cannot reference this step from another task.
9+
10+
However, you can optionally define a _step action_ in a `StepAction` custom resource (CR). This CR contains the action that a step performs. You can reference a `StepAction` object from a step to create a step that performs the action. You can also use resolvers to reference a `StepAction` definition that is available from an external source.
11+
12+
The following examples shows a `StepAction` CR named `apply-manifests-action`. This step action applies manifests from a source tree to your {OCP} environment:
13+
14+
[source,yaml]
15+
----
16+
apiVersion: tekton.dev/v1
17+
kind: StepAction
18+
metadata:
19+
name: apply-manifests-action
20+
spec:
21+
params:
22+
- name: working_dir
23+
description: The working directory where the source is located
24+
type: string # <1>
25+
default: "/workspace/source"
26+
- name: manifest_dir
27+
description: The directory in source that contains yaml manifests
28+
default: "k8s"
29+
results:
30+
- name: output
31+
description: The output of the oc apply command
32+
image: image-registry.openshift-image-registry.svc:5000/openshift/cli:latest
33+
env:
34+
- name: MANIFEST_DIR
35+
value: $(params.manifest_dir)
36+
workingDir: $(params.working_dir)
37+
script: |
38+
#!/usr/bin/env bash
39+
oc apply -f "$MANIFEST_DIR" | tee $(results.output)
40+
----
41+
<1> The `type` specification for a parameter is optional.
42+
43+
The `StepAction` CR does not include definitions of workspaces. Instead, the step action expects that the task that includes the action also provides the mounted source tree, typically using a workspace.
44+
45+
A `StepAction` object can define parameters and results. When you reference this object, you must specify the values for the parameters of the `StepAction` object in the definition of the step. The results of the `StepAction` object automatically become the results of the step.
46+
47+
[IMPORTANT]
48+
====
49+
To avoid malicious attacks that use the shell, the `StepAction` CR does not support using parameter values in a `script` value. Instead, you must use the `env:` section to define environment variables that contain the parameter values.
50+
====
51+
52+
The following example task includes a step that references the `apply-manifests-action` step action, provides the necessary parameters, and uses the result:
53+
54+
[source,yaml]
55+
----
56+
apiVersion: tekton.dev/v1
57+
kind: Task
58+
metadata:
59+
name: apply-manifests-with-action
60+
spec:
61+
workspaces:
62+
- name: source
63+
params:
64+
- name: manifest_dir
65+
description: The directory in source that contains yaml manifests
66+
type: string
67+
default: "k8s"
68+
steps:
69+
- name: apply
70+
ref:
71+
name: apply-manifests-action
72+
params:
73+
- name: working_dir
74+
value: "/workspace/source"
75+
- name: manifest_dir
76+
value: $(params.manifest_dir)
77+
- name: display_result
78+
script: 'echo $(step.apply.results.output)'
79+
----

modules/op-resolver-bundle.adoc

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
// // *openshift_pipelines/remote-pipelines-tasks-resolvers.adoc
55
:_mod-docs-content-type: PROCEDURE
66
[id="resolver-bundles-specify_{context}"]
7-
= Specifying a remote pipeline or task using the bundles resolver
7+
= Specifying a remote pipeline, task, or step action using the bundles resolver
88

9-
When creating a pipeline run, you can specify a remote pipeline from a Tekton bundle. When creating a pipeline or a task run, you can specify a remote task from a Tekton bundle.
9+
When creating a pipeline run, you can specify a remote pipeline from a Tekton bundle. When creating a pipeline or a task run, you can specify a remote task from a Tekton bundle. When creating a step within a task, you can reference a remote `StepAction` definition from a Tekton bundle.
1010

1111
.Procedure
1212

13-
* To specify a remote pipeline or task from a Tekton bundle, use the following reference format in the `pipelineRef` or `taskRef` spec:
13+
* To specify a remote pipeline, task, or `StepAction` definition from a Tekton bundle, use the following reference format in the `pipelineRef`, `taskRef`, or `step.ref` spec:
1414
+
1515
[source,yaml]
1616
----
@@ -49,6 +49,8 @@ When creating a pipeline run, you can specify a remote pipeline from a Tekton bu
4949
+
5050
If the pipeline or task requires additional parameters, specify values for these parameters in the `params` section of the specification of the pipeline, pipeline run, or task run. The `params` section of the `pipelineRef` or `taskRef` specification must contain only the parameters that the resolver supports.
5151

52+
.Examples
53+
5254
The following example pipeline run references a remote pipeline from a Tekton bundle:
5355

5456
[source,yaml]
@@ -121,3 +123,28 @@ spec:
121123
- name: sample-task-parameter
122124
value: test
123125
----
126+
127+
The following example task includes a step that references a `StepAction` definition from a Tekton bundle:
128+
129+
[source,yaml]
130+
----
131+
apiVersion: tekton.dev/v1
132+
kind: Task
133+
metadata:
134+
name: bundle-stepaction-reference-demo
135+
spec:
136+
steps:
137+
- name: example-step
138+
ref:
139+
resolver: bundles
140+
params:
141+
- name: bundle
142+
value: registry.example.com:5000/simple/new_task:latest
143+
- name: name
144+
value: hello-world-action
145+
- name: kind
146+
value: StepAction
147+
params:
148+
- name: sample-stepaction-parameter
149+
value: test
150+
----

modules/op-resolver-cluster.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ When creating a pipeline run, you can specify a pipeline that exists on the same
4646
+
4747
If the pipeline or task requires additional parameters, provide these parameters in `params`.
4848

49+
.Examples
50+
4951
The following example pipeline run references a pipeline from the same cluster:
5052

5153
[source,yaml]

modules/op-resolver-git-anon.adoc

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
:_mod-docs-content-type: PROCEDURE
66
[id="resolver-git-anon-specify_{context}"]
7-
= Specifying a remote pipeline or task by using the Git resolver for anonymous cloning
7+
= Specifying a remote pipeline, task, or step action by using the Git resolver for anonymous cloning
88

9-
When creating a pipeline run, you can specify a remote pipeline from a Git repository by using anonymous cloning. When creating a pipeline or a task run, you can specify a remote task from a Git repository.
9+
When creating a pipeline run, you can specify a remote pipeline from a Git repository by using anonymous cloning. When creating a pipeline or a task run, you can specify a remote task from a Git repository. When creating a step within a task, you can reference a remote `StepAction` definition from a Git repository.
1010

1111
.Procedure
1212

13-
. To specify a remote pipeline or task from a Git repository, use the following reference format in the `pipelineRef` or `taskRef` spec:
13+
* To specify a remote pipeline, task, or `StepAction` definition from a Git repository, use the following reference format in the `pipelineRef`, `taskRef`, or `step.ref` spec:
1414
+
1515
[source,yaml]
1616
----
@@ -52,6 +52,8 @@ To clone and fetch the repository anonymously, use the `url` parameter. Do not s
5252
+
5353
If the pipeline or task requires additional parameters, provide these parameters in `params`.
5454

55+
.Examples
56+
5557
The following example pipeline run references a remote pipeline from a Git repository:
5658

5759
[source,yaml]
@@ -97,7 +99,7 @@ spec:
9799
value: main
98100
- name: pathInRepo
99101
value: task/git-clone/0.6/git-clone.yaml
100-
params:
102+
params:
101103
- name: sample-task-parameter
102104
value: test
103105
----
@@ -123,4 +125,28 @@ spec:
123125
params:
124126
- name: sample-task-parameter
125127
value: test
126-
----
128+
----
129+
130+
The following example task includes a step that references a `StepAction` definition from a Git repository:
131+
132+
[source,yaml]
133+
----
134+
apiVersion: tekton.dev/v1
135+
kind: Task
136+
metadata:
137+
name: git-stepaction-reference-demo
138+
spec:
139+
steps:
140+
- name: example-step
141+
ref:
142+
resolver: git
143+
- name: url
144+
value: https://github.com/openshift-pipelines/tektoncd-catalog.git
145+
- name: revision
146+
value: p
147+
- name: pathInRepo
148+
value: stepactions/stepaction-git-clone/0.4.1/stepaction-git-clone.yaml
149+
params:
150+
- name: sample-stepaction-parameter
151+
value: test
152+
----

0 commit comments

Comments
 (0)