Skip to content

Commit 44b83dd

Browse files
committed
RHDEVDOCS-5238: Pipelines-as-code configuration and token scoping
1 parent 458273a commit 44b83dd

17 files changed

+284
-131
lines changed

cicd/pipelines/using-pipelines-as-code.adoc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
// :FeatureName: Pipelines as Code
109

10+
// :FeatureName: Pipelines as Code
1111
[role="_abstract"]
12-
With {pac}, cluster administrators and users with the required privileges can define pipeline templates as part of source code Git repositories. When triggered by a source code push or a pull request for the configured Git repository, the feature runs the pipeline and reports the status.
12+
With {pac}, cluster administrators and users with the required privileges can define pipeline templates as part of source code Git repositories. When triggered by a source code push or a pull request for the configured Git repository, {pac} runs the pipeline and reports the status.
1313

1414
[id="pac-key-features"]
1515
== Key features
1616
{pac} supports the following features:
1717

1818
* Pull request status and control on the platform hosting the Git repository.
1919
* GitHub Checks API to set the status of a pipeline run, including rechecks.
20-
* GitHub pull request and commit events.
20+
* GitHub pull request and commit events.
2121
* Pull request actions in comments, such as `/retest`.
2222
* Git events filtering and a separate pipeline for each event.
2323
* Automatic task resolution in {pipelines-shortname}, including local tasks, Tekton Hub, and remote URLs.
@@ -31,7 +31,7 @@ include::modules/op-installing-pipelines-as-code-on-an-openshift-cluster.adoc[le
3131
include::modules/op-installing-pipelines-as-code-cli.adoc[leveloffset=+1]
3232

3333
[id="using-pipelines-as-code-with-a-git-repository-hosting-service-provider"]
34-
== Using {pac} with a Git repository hosting service provider
34+
== Using {pac} with a Git repository hosting service provider
3535

3636
[role="_abstract"]
3737
After installing {pac}, cluster administrators can configure a Git repository hosting service provider. Currently, the following services are supported:
@@ -51,6 +51,8 @@ include::modules/op-using-pipelines-as-code-with-a-github-app.adoc[leveloffset=+
5151

5252
include::modules/op-creating-a-github-application-in-administrator-perspective.adoc[leveloffset=+2]
5353

54+
include::modules/op-scoping-github-token.adoc[leveloffset=+2]
55+
5456
include::modules/op-using-pipelines-as-code-with-github-webhook.adoc[leveloffset=+1]
5557

5658
.Additional resources
@@ -90,6 +92,8 @@ include::modules/op-using-repository-crd-with-pipelines-as-code.adoc[leveloffset
9092

9193
include::modules/op-setting-concurrency-limits-in-repository-crd.adoc[leveloffset=+2]
9294

95+
include::modules/op-changing-source-branch-in-repository-crd.adoc[leveloffset=+2]
96+
9397
include::modules/op-custom-parameter-expansion.adoc[leveloffset=+2]
9498

9599
include::modules/op-using-pipelines-as-code-resolver.adoc[leveloffset=+1]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// This module is included in the following assembly:
2+
//
3+
// *cicd/pipelines/using-pipelines-as-code.adoc
4+
5+
:_content-type: REFERENCE
6+
[id="changing-source-branch-in-repository-crd_{context}"]
7+
= Changing the source branch for the pipeline definition
8+
9+
[role="_abstract"]
10+
By default, when processing a push event or a pull request event, {pac} fetches the pipeline definition from the branch that triggered the event. You can use the `pipelinerun_provenance` setting in the `Repository` custom resource definition (CRD) to fetch the definition from the default branch configured on the Git repository provider, such as `main`, `master`, or `trunk`.
11+
12+
[source,yaml]
13+
----
14+
apiVersion: "pipelinesascode.tekton.dev/v1alpha1"
15+
kind: Repository
16+
metadata:
17+
name: my-repo
18+
namespace: target-namespace
19+
spec:
20+
# ...
21+
settings:
22+
pipelinerun_provenance: "default_branch"
23+
# ...
24+
----
25+
26+
[NOTE]
27+
====
28+
You can use this setting as a security precaution. With the default behaviour, {pac} uses the pipeline definition in the submitted pull request. With the `default-branch` setting, the pipeline definition must be merged into the default branch before it is run. This requirement ensures maximum possible verification of any changes during merge review.
29+
====

modules/op-customizing-pipelines-as-code-configuration.adoc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
:_content-type: REFERENCE
66
[id="customizing-pipelines-as-code-configuration_{context}"]
7-
= Customizing {pac} configuration
7+
= Customizing {pac} configuration
88

99
[role="_abstract"]
10-
To customize {pac}, cluster administrators can configure the following parameters using the `pipelines-as-code` config map in the `openshift-pipelines` namespace:
10+
To customize {pac}, cluster administrators can configure the following parameters in the `TektonConfig` custom resource, in the `pipelinesAsCode.settings` spec:
1111

1212
.Customizing {pac} configuration
1313
[options="header"]
@@ -17,11 +17,7 @@ To customize {pac}, cluster administrators can configure the following parameter
1717

1818
| `application-name` | The name of the application. For example, the name displayed in the GitHub Checks labels. | `"Pipelines as Code CI"`
1919

20-
| `max-keep-days` | The number of the days for which the executed pipeline runs are kept in the `openshift-pipelines` namespace.
21-
22-
Note that this `ConfigMap` setting does not affect the cleanups of a user's pipeline runs, which are controlled by the annotations on the pipeline run definition in the user's GitHub repository. | NA
23-
24-
| `secret-auto-create` | Indicates whether or not a secret should be automatically created using the token generated in the GitHub application. This secret can then be used with private repositories. | `enabled`
20+
| `secret-auto-create` | Indicates whether or not a secret should be automatically created using the token generated in the GitHub application. This secret can then be used with private repositories. | `enabled`
2521

2622
| `remote-tasks` | When enabled, allows remote tasks from pipeline run annotations. | `enabled`
2723

@@ -43,6 +39,15 @@ Note that this `ConfigMap` setting does not affect the cleanups of a user's pipe
4339

4440
| `auto-configure-repo-namespace-template` | Configures a template to automatically generate the namespace for your new repository, if `auto-configure-new-github-repo` is enabled. | `{repo_name}-pipelines`
4541

46-
| `error-log-snippet` | Enables or disables the view of a log snippet for the failed tasks, with an error in a pipeline. You can disable this parameter in the case of data leakage from your pipeline. | `enabled`
42+
| `error-log-snippet` | Enables or disables the view of a log snippet for the failed tasks, with an error in a pipeline. You can disable this parameter in the case of data leakage from your pipeline. | `true`
43+
44+
| `error-detection-from-container-logs` | Enables or disables the inspection of container logs to detect error message and expose them as annotations on the pull request. This setting applies only if you are using the GitHub app. | `true`
45+
46+
| `error-detection-max-number-of-lines` | The maximum number of lines inspected in the container logs to search for error messages. Set to `-1` to inspect an unlimited number of lines. | 50
4747

48-
|===
48+
| `secret-github-app-token-scoped` | If set to `true`, the GitHub access token that {pac} generates using the GitHub app is scoped only to the repository from which {pac} fetches the pipeline definition. If set to `false`, you can use both the `TektonConfig` custom resource and the `Repository` custom resource to scope the token to additional repositories. | `true`
49+
50+
| `secret-github-app-scope-extra-repos` | Additional repositories for scoping the generated GitHub access token. |
51+
52+
53+
|===

modules/op-installing-pipelines-as-code-on-an-openshift-cluster.adoc

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,28 @@
99
[role="_abstract"]
1010
{pac} is installed in the `openshift-pipelines` namespace when you install the {pipelines-title} Operator. For more details, see _Installing {pipelines-shortname}_ in the _Additional resources_ section.
1111

12-
To disable the default installation of {pac} with the Operator, set the value of the `enable` parameter to `false` in the `TektonConfig` custom resource.
12+
To disable the default installation of {pac} with the Operator, set the value of the `enable` parameter to `false` in the `TektonConfig` custom resource.
1313

1414
[source,yaml]
1515
----
16-
...
17-
spec:
18-
platforms:
19-
openshift:
20-
pipelinesAsCode:
21-
enable: false
22-
settings:
23-
application-name: Pipelines as Code CI
24-
auto-configure-new-github-repo: "false"
25-
bitbucket-cloud-check-source-ip: "true"
26-
hub-catalog-name: tekton
27-
hub-url: https://api.hub.tekton.dev/v1
28-
remote-tasks: "true"
29-
secret-auto-create: "true"
30-
...
16+
apiVersion: operator.tekton.dev/v1alpha1
17+
kind: TektonConfig
18+
metadata:
19+
name: config
20+
spec:
21+
platforms:
22+
openshift:
23+
pipelinesAsCode:
24+
enable: false
25+
settings:
26+
application-name: Pipelines as Code CI
27+
auto-configure-new-github-repo: "false"
28+
bitbucket-cloud-check-source-ip: "true"
29+
hub-catalog-name: tekton
30+
hub-url: https://api.hub.tekton.dev/v1
31+
remote-tasks: "true"
32+
secret-auto-create: "true"
33+
# ...
3134
----
3235

3336
Optionally, you can run the following command:
@@ -41,24 +44,27 @@ To enable the default installation of {pac} with the {pipelines-title} Operator,
4144

4245
[source,yaml]
4346
----
44-
...
45-
spec:
46-
platforms:
47-
openshift:
48-
pipelinesAsCode:
49-
enable: true
50-
settings:
51-
application-name: Pipelines as Code CI
52-
auto-configure-new-github-repo: "false"
53-
bitbucket-cloud-check-source-ip: "true"
54-
hub-catalog-name: tekton
55-
hub-url: https://api.hub.tekton.dev/v1
56-
remote-tasks: "true"
57-
secret-auto-create: "true"
58-
...
47+
apiVersion: operator.tekton.dev/v1alpha1
48+
kind: TektonConfig
49+
metadata:
50+
name: config
51+
spec:
52+
platforms:
53+
openshift:
54+
pipelinesAsCode:
55+
enable: true
56+
settings:
57+
application-name: Pipelines as Code CI
58+
auto-configure-new-github-repo: "false"
59+
bitbucket-cloud-check-source-ip: "true"
60+
hub-catalog-name: tekton
61+
hub-url: https://api.hub.tekton.dev/v1
62+
remote-tasks: "true"
63+
secret-auto-create: "true"
64+
# ...
5965
----
6066

61-
Optionally, you can run the following command:
67+
Optionally, you can run the following command:
6268

6369
[source,terminal]
6470
----

modules/op-installing-pipelines-operator-in-web-console.adoc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ If you have {pipelines-shortname} already installed on your cluster, the existin
1717
If you manually changed your existing installation, such as, changing the target namespace in the `config.operator.tekton.dev` CRD instance by making changes to the `resource name - cluster` field, then the upgrade path is not smooth. In such cases, the recommended workflow is to uninstall your installation and reinstall the {pipelines-title} Operator.
1818
====
1919

20-
The {pipelines-title} Operator now provides the option to choose the components that you want to install by specifying profiles as part of the `TektonConfig` CR. The `TektonConfig` CR is automatically installed when the Operator is installed.
20+
The {pipelines-title} Operator now provides the option to choose the components that you want to install by specifying profiles as part of the `TektonConfig` custom resource (CR). The `TektonConfig` CR is automatically installed when the Operator is installed.
2121
The supported profiles are:
2222

2323
* Lite: This installs only Tekton Pipelines.
24-
* Basic: This installs Tekton Pipelines and Tekton Triggers.
25-
* All: This is the default profile used when the `TektonConfig` CR is installed. This profile installs all of the Tekton components: Tekton Pipelines, Tekton Triggers, Tekton Addons (which include `ClusterTasks`, `ClusterTriggerBindings`, `ConsoleCLIDownload`, `ConsoleQuickStart` and `ConsoleYAMLSample` resources).
24+
* Basic: This installs Tekton Pipelines, Tekton Triggers, and Tekton Chains.
25+
* All: This is the default profile used when the `TektonConfig` CR is installed. This profile installs all of the Tekton components, including Tekton Pipelines, Tekton Triggers, Tekton Chains, {pac}, and Tekton Addons. Tekton Addons includes the `ClusterTasks`, `ClusterTriggerBindings`, `ConsoleCLIDownload`, `ConsoleQuickStart`, and `ConsoleYAMLSample` resources.
2626
2727
[discrete]
2828
.Procedure
@@ -47,7 +47,7 @@ The supported profiles are:
4747
[NOTE]
4848
====
4949
Starting with {product-title} 4.11, the `preview` and `stable` channels for installing and upgrading the {pipelines-title} Operator are not available. However, in {product-title} 4.10 and earlier versions, you can use the `preview` and `stable` channels for installing and upgrading the Operator.
50-
====
50+
====
5151

5252
. Click *Install*. You will see the Operator listed on the *Installed Operators* page.
5353
+
@@ -74,7 +74,7 @@ $ oc get tektonconfig config
7474
.Example output
7575
----
7676
NAME VERSION READY REASON
77-
config 1.9.2 True
77+
config 1.9.2 True
7878
----
7979
+
8080
If the *READY* condition is *True*, the Operator and its components have been installed successfully.
@@ -89,12 +89,11 @@ $ oc get tektonpipeline,tektontrigger,tektonaddon,pac
8989
.Example output
9090
----
9191
NAME VERSION READY REASON
92-
tektonpipeline.operator.tekton.dev/pipeline v0.41.1 True
92+
tektonpipeline.operator.tekton.dev/pipeline v0.41.1 True
9393
NAME VERSION READY REASON
94-
tektontrigger.operator.tekton.dev/trigger v0.22.2 True
94+
tektontrigger.operator.tekton.dev/trigger v0.22.2 True
9595
NAME VERSION READY REASON
96-
tektonaddon.operator.tekton.dev/addon 1.9.2 True
96+
tektonaddon.operator.tekton.dev/addon 1.9.2 True
9797
NAME VERSION READY REASON
98-
openshiftpipelinesascode.operator.tekton.dev/pipelines-as-code v0.15.5 True
98+
openshiftpipelinesascode.operator.tekton.dev/pipelines-as-code v0.15.5 True
9999
----
100-

modules/op-monitoring-pipeline-run-status-using-pipelines-as-code.adoc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
:_content-type: REFERENCE
66
[id="monitoring-pipeline-run-status-using-pipelines-as-code_{context}"]
7-
= Monitoring pipeline run status using {pac}
7+
= Monitoring pipeline run status using {pac}
88

99
[role="_abstract"]
1010
Depending on the context and supported tools, you can monitor the status of a pipeline run in different ways.
@@ -25,20 +25,18 @@ When {pac} detects an error in one of the tasks of a pipeline, a small snippet c
2525
[discrete]
2626
.Annotations for log error snippets
2727

28-
In the {pac} config map, if you set the `error-detection-from-container-logs` parameter to `true`, {pac} detects the errors from the container logs and adds them as annotations on the pull request where the error occurred.
28+
In the `TektonConfig` custom resource, in the `pipelinesAsCode.settings` spec, you can set the `error-detection-from-container-logs` parameter to `true`. In this case, {pac} detects the errors from the container logs and adds them as annotations on the pull request where the error occurred.
2929

30-
[IMPORTANT]
31-
====
32-
This feature is in Technology Preview.
33-
====
30+
:FeatureName: Adding annotations for log error snippets
31+
include::snippets/technology-preview.adoc[]
3432

3533
Currently, {pac} supports only the simple cases where the error looks like `makefile` or `grep` output of the following format:
3634
[source,yaml]
3735
----
3836
<filename>:<line>:<column>: <error message>
3937
----
4038

41-
You can customize the regular expression used to detect the errors with the `error-detection-simple-regexp` field. The regular expression uses named groups to give flexibility on how to specify the matching. The groups needed to match are filename, line, and error. You can view the {pac} config map for the default regular expression.
39+
You can customize the regular expression used to detect the errors with the `error-detection-simple-regexp` parameter. The regular expression uses named groups to give flexibility on how to specify the matching. The groups needed to match are `filename`, `line`, and `error`. You can view the {pac} config map for the default regular expression.
4240

4341
[NOTE]
4442
====
@@ -51,7 +49,7 @@ For webhook, when the event is a pull request, the status is added as a comment
5149

5250
[discrete]
5351
.Failures
54-
If a namespace is matched to a `Repository` CRD, {pac} emits its failure log messages in the Kubernetes events inside the namespace.
52+
If a namespace is matched to a `Repository` custom resource definition (CRD), {pac} emits its failure log messages in the Kubernetes events inside the namespace.
5553

5654
[discrete]
5755
.Status associated with Repository CRD
@@ -73,4 +71,3 @@ Using the `tkn pac describe` command, you can extract the status of the runs ass
7371
[discrete]
7472
.Notifications
7573
{pac} does not manage notifications. If you need to have notifications, use the `finally` feature of pipelines.
76-

modules/op-running-pipeline-run-using-pipelines-as-code.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
:_content-type: REFERENCE
66
[id="running-pipeline-run-using-pipelines-as-code_{context}"]
7-
= Running a pipeline run using {pac}
7+
= Running a pipeline run using {pac}
88

99
[role="_abstract"]
1010
With default configuration, {pac} runs any pipeline run in the `.tekton/` directory of the default branch of repository, when specified events such as pull request or push occurs on the repository. For example, if a pipeline run on the default branch has the annotation `pipelinesascode.tekton.dev/on-event: "[pull_request]"`, it will run whenever a pull request event occurs.
@@ -28,7 +28,7 @@ If the pull request author does not meet the requirements, another user who meet
2828

2929
[discrete]
3030
.Pipeline run execution
31-
A pipeline run always runs in the namespace of the `Repository` CRD associated with the repository that generated the event.
31+
A pipeline run always runs in the namespace of the `Repository` custom resource definition (CRD) associated with the repository that generated the event.
3232

3333
You can observe the execution of your pipeline runs using the `tkn pac` CLI tool.
3434

0 commit comments

Comments
 (0)