이 콘텐츠는 선택한 언어로 제공되지 않습니다.

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

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.
Tip

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

$ tkn pac [command or options] [arguments]
Copy to Clipboard Toggle word wrap

7.1.2. Global options

$ tkn pac --help
Copy to Clipboard Toggle word wrap

7.1.3. Utility commands

bootstrap
Expand
CommandDescription

tkn pac bootstrap

Installs and configures Pipelines as Code for Git repository hosting service providers, such as GitHub and GitHub Enterprise.

tkn pac bootstrap --nightly

Installs the nightly build of Pipelines as Code.

tkn pac bootstrap --route-url <public_url_to_ingress_spec>

Overrides the OpenShift route URL.

By default, tkn pac bootstrap detects the OpenShift route, which is automatically associated with the Pipelines as Code controller service.

If you do not have an OpenShift Container Platform cluster, it asks you for the public URL that points to the ingress endpoint.

tkn pac bootstrap github-app

Create a GitHub application and secrets in the openshift-pipelines namespace.

repository
Expand
CommandDescription

tkn pac create repository

Creates a new Pipelines as Code repository and a namespace based on the pipeline run template.

tkn pac list

Lists all the Pipelines as Code repositories and displays the last status of the associated runs.

tkn pac repo describe

Describes a Pipelines as Code repository and the associated runs.

generate
Expand
CommandDescription

tkn pac generate

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 setup.py file at the repository root, the pylint task is automatically added to the generated pipeline run.

resolve
Expand
CommandDescription

tkn pac resolve

Executes a pipeline run as if it is owned by the Pipelines as Code on service.

tkn pac resolve -f .tekton/pull-request.yaml | oc apply -f -

Displays the status of a live pipeline run that uses the template in .tekton/pull-request.yaml.

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.

tkn pac resolve -f .tekton/pr.yaml -p revision=main -p repo_name=<repository_name>

Executes a pipeline run by overriding default parameter values derived from the Git repository.

The -f option can also accept a directory path and apply the tkn pac resolve command on all .yaml or .yml files in that directory. You can also use the -f flag multiple times in the same command.

You can override the default information gathered from the Git repository by specifying parameter values using the -p option. For example, you can use a Git branch as a revision and a different repository name.

cel
Expand
CommandDescription

tkn pac cel

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.

Important

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>]
Copy to Clipboard Toggle word wrap
Expand
OptionDescription

-b, --body

Specify the JSON payload file.

-H, --headers

Specify the headers file (plain text, JSON, or gosmee script).

-p, --provider

Optional: specify the Git provider (auto, github, gitlab, bitbucket-cloud, bitbucket-datacenter, gitea).

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
    Copy to Clipboard Toggle word wrap
  • JSON header format

    {
      "X-GitHub-Event": "pull_request",
      "Content-Type": "application/json",
      "User-Agent": "GitHub-Hookshot/abc123"
    }
    Copy to Clipboard Toggle word wrap
  • Gosmee-generated shell scripts

    The tkn pac cel command automatically detects and parses headers from gosmee --save scripts. The following is an example using GitHub:

    #!/usr/bin/env bash
    curl -X POST "http://localhost:8080/" \
      -H "X-GitHub-Event: pull_request" \
      -H "Content-Type: application/json" \
      -H "User-Agent: GitHub-Hookshot/abc123" \
      -d @payload.json
    Copy to Clipboard Toggle word wrap

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
Copy to Clipboard Toggle word wrap

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
Note

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"
Copy to Clipboard Toggle word wrap

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

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

  1. In the Administrator perspective of the web console, go to Administration CustomResourceDefinitions.
  2. Use the Search by name field to search for the tektonconfigs.operator.tekton.dev custom resource definition (CRD) and click TektonConfig to view the CRD Details page.
  3. Click the Instances tab.
  4. Click the config instance to view the TektonConfig CR details.
  5. Click the YAML tab.
  6. Edit the loglevel. fields under the .options.configMaps.pac-config-logging.data parameter based on your requirements.

    Example TektonConfig CR with the Pipelines as Code log level fields set to warn

    apiVersion: operator.tekton.dev/v1alpha1
    kind: TektonConfig
    metadata:
      name: config
    spec:
      platforms:
        openshift:
          pipelinesAsCode:
            options:
              configMaps:
                pac-config-logging:
                  data:
                    loglevel.pac-watcher: warn 
    1
    
                    loglevel.pipelines-as-code-webhook: warn 
    2
    
                    loglevel.pipelinesascode: warn 
    3
    
                    zap-logger-config: |
                      {
                        "level": "info",
                        "development": false,
                        "sampling": {
                          "initial": 100,
                          "thereafter": 100
                        },
                        "outputPaths": ["stdout"],
                        "errorOutputPaths": ["stderr"],
                        "encoding": "json",
                        "encoderConfig": {
                          "timeKey": "ts",
                          "levelKey": "level",
                          "nameKey": "logger",
                          "callerKey": "caller",
                          "messageKey": "msg",
                          "stacktraceKey": "stacktrace",
                          "lineEnding": "",
                          "levelEncoder": "",
                          "timeEncoder": "iso8601",
                          "durationEncoder": "",
                          "callerEncoder": ""
                        }
                      }
    Copy to Clipboard Toggle word wrap

    1
    The log level for the pipelines-as-code-watcher component.
    2
    The log level for the pipelines-as-code-webhook component.
    3
    The log level for the pipelines-as-code-controller component.
  7. Optional: Create a custom logging config map for the Pipelines as Code components by changing the .env.value for each component under the .options.deployments field. The example below shows the configuration with the custom config map called custom-pac-config-logging.

    Example TektonConfig CR with the Pipelines as Code custom logging config map

    apiVersion: operator.tekton.dev/v1alpha1
    kind: TektonConfig
    metadata:
      name: config
    spec:
      platforms:
        openshift:
          pipelinesAsCode:
            enable: true
            options:
              configMaps:
                custom-pac-config-logging:
                  data:
                    loglevel.pac-watcher: warn
                    loglevel.pipelines-as-code-webhook: warn
                    loglevel.pipelinesascode: warn
                    zap-logger-config: |
                      {
                        "level": "info",
                        "development": false,
                        "sampling": {
                          "initial": 100,
                          "thereafter": 100
                        },
                        "outputPaths": ["stdout"],
                        "errorOutputPaths": ["stderr"],
                        "encoding": "json",
                        "encoderConfig": {
                          "timeKey": "ts",
                          "levelKey": "level",
                          "nameKey": "logger",
                          "callerKey": "caller",
                          "messageKey": "msg",
                          "stacktraceKey": "stacktrace",
                          "lineEnding": "",
                          "levelEncoder": "",
                          "timeEncoder": "iso8601",
                          "durationEncoder": "",
                          "callerEncoder": ""
                        }
                      }
              deployments:
                pipelines-as-code-controller:
                  spec:
                    template:
                      spec:
                        containers:
                        - name: pac-controller
                          env:
                          - name: CONFIG_LOGGING_NAME
                            value: custom-pac-config-logging
                pipelines-as-code-watcher:
                  spec:
                    template:
                      spec:
                        containers:
                        - name: pac-watcher
                          env:
                          - name: CONFIG_LOGGING_NAME
                            value: custom-pac-config-logging
                pipelines-as-code-webhook:
                  spec:
                    template:
                      spec:
                        containers:
                        - name: pac-webhook
                          env:
                          - name: CONFIG_LOGGING_NAME
                            value: custom-pac-config-logging
    Copy to Clipboard Toggle word wrap

7.3. Splitting Pipelines as Code logs by namespace

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 
1
Copy to Clipboard Toggle word wrap
1
Replace pipelines-as-code-controller-<unique-id> with the Pipelines as Code controller name.
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동