Este conteúdo não está disponível no idioma selecionado.
Chapter 7. Pipelines as Code command reference
You can use the tkn pac CLI tool to control Pipelines as Code. You can also configure Pipelines as Code logging with the TektonConfig custom resource and use the oc command to view Pipelines as Code logs.
7.1. Pipelines as Code command reference Copiar o linkLink copiado para a área de transferência!
The tkn pac CLI tool offers the following capabilities:
- Bootstrap Pipelines as Code installation and configuration.
- Create a new Pipelines as Code repository.
- List all Pipelines as Code repositories.
- Describe a Pipelines as Code repository and the associated runs.
- Generate a simple pipeline run to get started.
- Resolve a pipeline run as if it was executed by Pipelines as Code.
You can use the commands corresponding to the capabilities for testing and experimentation, so that you don’t have to make changes to the Git repository containing the application source code.
7.1.1. Basic syntax Copiar o linkLink copiado para a área de transferência!
tkn pac [command or options] [arguments]
$ tkn pac [command or options] [arguments]
7.1.2. Global options Copiar o linkLink copiado para a área de transferência!
tkn pac --help
$ tkn pac --help
7.1.3. Utility commands Copiar o linkLink copiado para a área de transferência!
- bootstrap
| Command | Description |
|---|---|
|
| Installs and configures Pipelines as Code for Git repository hosting service providers, such as GitHub and GitHub Enterprise. |
|
| Installs the nightly build of Pipelines as Code. |
|
| Overrides the OpenShift route URL.
By default, If you do not have an OpenShift Container Platform cluster, it asks you for the public URL that points to the ingress endpoint. |
|
|
Create a GitHub application and secrets in the |
- repository
| Command | Description |
|---|---|
|
| Creates a new Pipelines as Code repository and a namespace based on the pipeline run template. |
|
| Lists all the Pipelines as Code repositories and displays the last status of the associated runs. |
|
| Describes a Pipelines as Code repository and the associated runs. |
- generate
| Command | Description |
|---|---|
|
| Generates a simple pipeline run. When executed from the directory containing the source code, it automatically detects current Git information. In addition, it uses basic language detection capability and adds extra tasks depending on the language.
For example, if it detects a |
- resolve
| Command | Description |
|---|---|
|
| Executes a pipeline run as if it is owned by the Pipelines as Code on service. |
|
|
Displays the status of a live pipeline run that uses the template in Combined with a Kubernetes installation running on your local machine, you can observe the pipeline run without generating a new commit. If you run the command from a source code repository, it attempts to detect the current Git information and automatically resolve parameters such as current revision or branch. |
|
| Executes a pipeline run by overriding default parameter values derived from the Git repository.
The
You can override the default information gathered from the Git repository by specifying parameter values using the |
- cel
| Command | Description |
|---|---|
|
| Evaluate CEL (Common Expression Language) expressions against webhook payloads and headers. Because the command requires access to the raw webhook payload and header data provided by the Git provider, it is intended for administrator use for testing and debugging event filtering logic in Pipelines as Code. |
The tkn pac cel command is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
The tkn pac cel command uses the following syntax:
tkn pac cel -b <body.json> -H <headers.txt> [-p <provider>]
tkn pac cel -b <body.json> -H <headers.txt> [-p <provider>]
| Option | Description |
|---|---|
|
| Specify the JSON payload file. |
|
| Specify the headers file (plain text, JSON, or gosmee script). |
|
|
Optional: specify the Git provider ( |
Header formats
The tkn pac cel command supports the following header formats:
Plain HTTP header format
X-GitHub-Event: pull_request Content-Type: application/json User-Agent: GitHub-Hookshot/abc123
X-GitHub-Event: pull_request Content-Type: application/json User-Agent: GitHub-Hookshot/abc123Copy to Clipboard Copied! Toggle word wrap Toggle overflow JSON header format
{ "X-GitHub-Event": "pull_request", "Content-Type": "application/json", "User-Agent": "GitHub-Hookshot/abc123" }{ "X-GitHub-Event": "pull_request", "Content-Type": "application/json", "User-Agent": "GitHub-Hookshot/abc123" }Copy to Clipboard Copied! Toggle word wrap Toggle overflow Gosmee-generated shell scripts
The
tkn pac celcommand automatically detects and parses headers from gosmee--savescripts. The following is an example using GitHub:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Interactive mode
The tkn pac cel command displays an interactive CEL expression prompt when executed in a terminal. Expression history is navigable using arrow keys and persists between sessions. Pressing Enter on an empty line exits the prompt.
Non-interactive mode
The tkn pac cel command accepts CEL expressions using standard input (stdin), allowing evaluation without using the interactive prompt. For example:
echo 'event == "pull_request"' | tkn pac cel -b body.json -H headers.txt
echo 'event == "pull_request"' | tkn pac cel -b body.json -H headers.txt
Available variables
The tkn pac cel command exposes the following variables that can be used in CEL expressions to filter or inspect events:
-
event: Event type (push,pull_request) -
target_branch: Target branch name -
source_branch: Source branch name -
target_url: Target repository URL -
source_url: Source repository URL -
event_title: Pull request title or commit message -
body.*: All fields from the webhook payload -
headers.*: All HTTP headers -
files.*: Always empty in CLI mode -
pac.*: All PAC parameters for backward compatibility
When evaluating CEL expressions locally using the CLI, files.* variables are always empty, and functions such as fileChanged, fileDeleted, and fileModified are unavailable.
Example expressions
The following expressions illustrate typical use cases, including event filtering, branch matching, and header inspection:
event == "pull_request" && target_branch == "main"
event == "pull_request" && source_branch.matches(".*feat/.*")
body.action == "synchronize"
!body.pull_request.draft
headers["x-github-event"] == "pull_request"
event == "pull_request" && target_branch == "main"
event == "pull_request" && source_branch.matches(".*feat/.*")
body.action == "synchronize"
!body.pull_request.draft
headers["x-github-event"] == "pull_request"
History storage
The tkn pac cel command maintains a persistent history and creates the cel-history directory automatically if it does not exist in the following paths:
-
Linux or macOS:
~/.cache/tkn-pac/cel-history -
Windows:
%USERPROFILE%\.cache\tkn-pac\cel-history
7.2. Configuring Pipelines as Code logging Copiar o linkLink copiado para a área de transferência!
You can configure Pipelines as Code logging by editing the pac-config-logging config map in the TektonConfig custom resource (CR).
Prerequisites
- You have Pipelines as Code installed on your cluster.
Procedure
-
In the Administrator perspective of the web console, go to Administration
CustomResourceDefinitions. -
Use the Search by name field to search for the
tektonconfigs.operator.tekton.devcustom resource definition (CRD) and click TektonConfig to view the CRD Details page. - Click the Instances tab.
-
Click the config instance to view the
TektonConfigCR details. - Click the YAML tab.
Edit the
loglevel.fields under the.options.configMaps.pac-config-logging.dataparameter based on your requirements.Example
TektonConfigCR with the Pipelines as Code log level fields set towarnCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Create a custom logging config map for the Pipelines as Code components by changing the
.env.valuefor each component under the.options.deploymentsfield. The example below shows the configuration with the custom config map calledcustom-pac-config-logging.Example
TektonConfigCR with the Pipelines as Code custom logging config mapCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.3. Splitting Pipelines as Code logs by namespace Copiar o linkLink copiado para a área de transferência!
Pipelines as Code logs contain the namespace information to make it possible to filter logs or split the logs by a particular namespace. For example, to view the Pipelines as Code logs related to the mynamespace namespace, enter the following command:
oc logs pipelines-as-code-controller-<unique-id> -n openshift-pipelines | grep mynamespace
$ oc logs pipelines-as-code-controller-<unique-id> -n openshift-pipelines | grep mynamespace
- 1
- Replace
pipelines-as-code-controller-<unique-id>with the Pipelines as Code controller name.