Pipelines CLI (tkn) reference
The tkn CLI reference for OpenShift Pipelines
Abstract
Chapter 1. Installing tkn Copy linkLink copied to clipboard!
Use the CLI tool to manage Red Hat OpenShift Pipelines from a terminal. You can install the CLI tool on different platforms.
Both the archives and the RPMs contain the following executables:
-
tkn
-
tkn-pac
-
opc
Running Red Hat OpenShift Pipelines with the opc
CLI tool 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.
1.1. Installing the Red Hat OpenShift Pipelines CLI on Linux Copy linkLink copied to clipboard!
For Linux distributions, you can download the CLI as a tar.gz
archive.
Procedure
Download the relevant CLI tool.
Unpack the archive:
tar xvzf <file>
$ tar xvzf <file>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Add the location of your
tkn
,tkn-pac
, andopc
files to yourPATH
environment variable. To check your
PATH
, run the following command:echo $PATH
$ echo $PATH
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2. Installing the Red Hat OpenShift Pipelines CLI on Linux using an RPM Copy linkLink copied to clipboard!
For Red Hat Enterprise Linux (RHEL) version 8, you can install the Red Hat OpenShift Pipelines CLI as an RPM.
Prerequisites
- You have an active OpenShift Container Platform subscription on your Red Hat account.
- You have root or sudo privileges on your local system.
Procedure
Register with Red Hat Subscription Manager:
subscription-manager register
# subscription-manager register
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Pull the latest subscription data:
subscription-manager refresh
# subscription-manager refresh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow List the available subscriptions:
subscription-manager list --available --matches '*pipelines*'
# subscription-manager list --available --matches '*pipelines*'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the output for the previous command, find the pool ID for your OpenShift Container Platform subscription and attach the subscription to the registered system:
subscription-manager attach --pool=<pool_id>
# subscription-manager attach --pool=<pool_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enable the repositories required by Red Hat OpenShift Pipelines:
Linux (x86_64, amd64)
subscription-manager repos --enable="pipelines-1.18-for-rhel-8-x86_64-rpms"
# subscription-manager repos --enable="pipelines-1.18-for-rhel-8-x86_64-rpms"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Linux on IBM zSystems and IBM® LinuxONE (s390x)
subscription-manager repos --enable="pipelines-1.18-for-rhel-8-s390x-rpms"
# subscription-manager repos --enable="pipelines-1.18-for-rhel-8-s390x-rpms"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Linux on IBM Power (ppc64le)
subscription-manager repos --enable="pipelines-1.18-for-rhel-8-ppc64le-rpms"
# subscription-manager repos --enable="pipelines-1.18-for-rhel-8-ppc64le-rpms"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Linux on ARM (aarch64, arm64)
subscription-manager repos --enable="pipelines-1.18-for-rhel-8-aarch64-rpms"
# subscription-manager repos --enable="pipelines-1.18-for-rhel-8-aarch64-rpms"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Install the
openshift-pipelines-client
package:yum install openshift-pipelines-client
# yum install openshift-pipelines-client
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
After you install the CLI, it is available using the tkn
command:
tkn version
$ tkn version
1.3. Installing the Red Hat OpenShift Pipelines CLI on Windows Copy linkLink copied to clipboard!
For Windows, you can download the CLI as a zip
archive.
Procedure
- Download the CLI tool.
- Extract the archive with a ZIP program.
-
Add the location of your
tkn
,tkn-pac
, andopc
files to yourPATH
environment variable. To check your
PATH
, run the following command:path
C:\> path
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4. Installing the Red Hat OpenShift Pipelines CLI on macOS Copy linkLink copied to clipboard!
For macOS, you can download the CLI as a tar.gz
archive.
Procedure
Download the relevant CLI tool.
- Unpack and extract the archive.
-
Add the location of your
tkn
,tkn-pac
, andopc
files to yourPATH
environment variable. To check your
PATH
, run the following command:echo $PATH
$ echo $PATH
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 2. Configuring the OpenShift Pipelines tkn CLI Copy linkLink copied to clipboard!
Configure the Red Hat OpenShift Pipelines tkn
CLI to enable tab completion.
2.1. Enabling tab completion Copy linkLink copied to clipboard!
After you install the tkn
CLI, you can enable tab completion to automatically complete tkn
commands or suggest options when you press Tab.
Prerequisites
-
You must have the
tkn
CLI tool installed. -
You must have
bash-completion
installed on your local system.
Procedure
The following procedure enables tab completion for Bash.
Save the Bash completion code to a file:
tkn completion bash > tkn_bash_completion
$ tkn completion bash > tkn_bash_completion
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the file to
/etc/bash_completion.d/
:sudo cp tkn_bash_completion /etc/bash_completion.d/
$ sudo cp tkn_bash_completion /etc/bash_completion.d/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, you can save the file to a local directory and source it from your
.bashrc
file instead.
Tab completion is enabled when you open a new terminal.
Chapter 3. OpenShift Pipelines tkn reference Copy linkLink copied to clipboard!
This section lists the basic tkn
CLI commands.
3.1. Basic syntax Copy linkLink copied to clipboard!
tkn [command or options] [arguments…]
3.2. Global options Copy linkLink copied to clipboard!
--help, -h
3.3. Utility commands Copy linkLink copied to clipboard!
3.3.1. tkn Copy linkLink copied to clipboard!
Parent command for tkn
CLI.
Example: Display all options
tkn
$ tkn
3.3.2. completion [shell] Copy linkLink copied to clipboard!
Print shell completion code which must be evaluated to provide interactive completion. Supported shells are bash
and zsh
.
Example: Completion code for bash
shell
tkn completion bash
$ tkn completion bash
3.3.3. version Copy linkLink copied to clipboard!
Print version information of the tkn
CLI.
Example: Check the tkn
version
tkn version
$ tkn version
3.4. Pipelines management commands Copy linkLink copied to clipboard!
3.4.1. pipeline Copy linkLink copied to clipboard!
Manage pipelines.
Example: Display help
tkn pipeline --help
$ tkn pipeline --help
3.4.2. pipeline delete Copy linkLink copied to clipboard!
Delete a pipeline.
Example: Delete a pipeline from a namespace
tkn pipeline delete <pipeline_name> -n <namespace_name>
$ tkn pipeline delete <pipeline_name> -n <namespace_name>
3.4.3. pipeline describe Copy linkLink copied to clipboard!
Describe a pipeline.
Example: Describe a pipeline
tkn pipeline describe <pipeline_name>
$ tkn pipeline describe <pipeline_name>
3.4.4. pipeline list Copy linkLink copied to clipboard!
Display a list of pipelines.
Example: Display a list of pipelines
tkn pipeline list
$ tkn pipeline list
3.4.5. pipeline logs Copy linkLink copied to clipboard!
Display the logs for a specific pipeline.
Example: Stream the live logs for a pipeline
tkn pipeline logs -f <pipeline_name>
$ tkn pipeline logs -f <pipeline_name>
3.4.6. pipeline start Copy linkLink copied to clipboard!
Start a pipeline.
Example: Start a pipeline
tkn pipeline start <pipeline_name>
$ tkn pipeline start <pipeline_name>
3.5. Pipeline run commands Copy linkLink copied to clipboard!
3.5.1. pipelinerun Copy linkLink copied to clipboard!
Manage pipeline runs.
Example: Display help
tkn pipelinerun -h
$ tkn pipelinerun -h
3.5.2. pipelinerun cancel Copy linkLink copied to clipboard!
Cancel a pipeline run.
Example: Cancel a pipeline run from a namespace
tkn pipelinerun cancel <pipeline_run_name> -n <namespace_name>
$ tkn pipelinerun cancel <pipeline_run_name> -n <namespace_name>
3.5.3. pipelinerun delete Copy linkLink copied to clipboard!
Delete a pipeline run.
Example: Delete pipeline runs from a namespace
tkn pipelinerun delete <pipeline_run_name_1> <pipeline_run_name_2> -n <namespace_name>
$ tkn pipelinerun delete <pipeline_run_name_1> <pipeline_run_name_2> -n <namespace_name>
Example: Delete all pipeline runs from a namespace, except the five most recently executed pipeline runs
tkn pipelinerun delete -n <namespace_name> --keep 5
$ tkn pipelinerun delete -n <namespace_name> --keep 5
- 1
- Replace
5
with the number of most recently executed pipeline runs you want to retain.
Example: Delete all pipelines
tkn pipelinerun delete --all
$ tkn pipelinerun delete --all
Starting with Red Hat OpenShift Pipelines 1.6, the tkn pipelinerun delete --all
command does not delete any resources that are in the running state.
3.5.4. pipelinerun describe Copy linkLink copied to clipboard!
Describe a pipeline run.
Example: Describe a pipeline run in a namespace
tkn pipelinerun describe <pipeline_run_name> -n <namespace_name>
$ tkn pipelinerun describe <pipeline_run_name> -n <namespace_name>
3.5.5. pipelinerun list Copy linkLink copied to clipboard!
List pipeline runs.
Example: Display a list of pipeline runs in a namespace
tkn pipelinerun list -n <namespace_name>
$ tkn pipelinerun list -n <namespace_name>
3.5.6. pipelinerun logs Copy linkLink copied to clipboard!
Display the logs of a pipeline run.
Example: Display the logs of a pipeline run with all tasks and steps in a namespace
tkn pipelinerun logs <pipeline_run_name> -a -n <namespace_name>
$ tkn pipelinerun logs <pipeline_run_name> -a -n <namespace_name>
3.6. Task management commands Copy linkLink copied to clipboard!
3.6.1. task Copy linkLink copied to clipboard!
Manage tasks.
Example: Display help
tkn task -h
$ tkn task -h
3.6.2. task delete Copy linkLink copied to clipboard!
Delete a task.
Example: Delete tasks from a namespace
tkn task delete <task_name_1> <task_name_2> -n <namespace_name>
$ tkn task delete <task_name_1> <task_name_2> -n <namespace_name>
3.6.3. task describe Copy linkLink copied to clipboard!
Describe a task.
Example: Describe a task in a namespace
tkn task describe <task_name> -n <namespace_name>
$ tkn task describe <task_name> -n <namespace_name>
3.6.4. task list Copy linkLink copied to clipboard!
List tasks.
Example: List all the tasks in a namespace
tkn task list -n <namespace_name>
$ tkn task list -n <namespace_name>
3.6.5. task start Copy linkLink copied to clipboard!
Start a task.
Example: Start a task in a namespace
tkn task start <task_name> -s <service_account_name> -n <namespace_name>
$ tkn task start <task_name> -s <service_account_name> -n <namespace_name>
3.7. Task run commands Copy linkLink copied to clipboard!
3.7.1. taskrun Copy linkLink copied to clipboard!
Manage task runs.
Example: Display help
tkn taskrun -h
$ tkn taskrun -h
3.7.2. taskrun cancel Copy linkLink copied to clipboard!
Cancel a task run.
Example: Cancel a task run from a namespace
tkn taskrun cancel <task_run_name> -n <namespace_name>
$ tkn taskrun cancel <task_run_name> -n <namespace_name>
3.7.3. taskrun delete Copy linkLink copied to clipboard!
Delete a TaskRun.
Example: Delete task runs from a namespace
tkn taskrun delete <task_run_name_1> <task_run_name_2> -n <namespace_name>
$ tkn taskrun delete <task_run_name_1> <task_run_name_2> -n <namespace_name>
Example: Delete all but the five most recently executed task runs from a namespace
tkn taskrun delete -n <namespace_name> --keep 5
$ tkn taskrun delete -n <namespace_name> --keep 5
- 1
- Replace
5
with the number of most recently executed task runs you want to retain.
3.7.4. taskrun describe Copy linkLink copied to clipboard!
Describe a task run.
Example: Describe a task run in a namespace
tkn taskrun describe <task_run_name> -n <namespace_name>
$ tkn taskrun describe <task_run_name> -n <namespace_name>
3.7.5. taskrun list Copy linkLink copied to clipboard!
List task runs.
Example: List all the task runs in a namespace
tkn taskrun list -n <namespace_name>
$ tkn taskrun list -n <namespace_name>
3.7.6. taskrun logs Copy linkLink copied to clipboard!
Display task run logs.
Example: Display live logs for a task run in a namespace
tkn taskrun logs -f <task_run_name> -n <namespace_name>
$ tkn taskrun logs -f <task_run_name> -n <namespace_name>
3.8. Pipeline Resource management commands Copy linkLink copied to clipboard!
3.8.1. resource Copy linkLink copied to clipboard!
Manage Pipeline Resources.
Example: Display help
tkn resource -h
$ tkn resource -h
3.8.2. resource create Copy linkLink copied to clipboard!
Create a Pipeline Resource.
Example: Create a Pipeline Resource in a namespace
tkn resource create -n myspace
$ tkn resource create -n myspace
This is an interactive command that asks for input on the name of the Resource, type of the Resource, and the values based on the type of the Resource.
3.8.3. resource delete Copy linkLink copied to clipboard!
Delete a Pipeline Resource.
Example: Delete the myresource
Pipeline Resource from a namespace
tkn resource delete myresource -n myspace
$ tkn resource delete myresource -n myspace
3.8.4. resource describe Copy linkLink copied to clipboard!
Describe a Pipeline Resource.
Example: Describe the myresource
Pipeline Resource
tkn resource describe myresource -n myspace
$ tkn resource describe myresource -n myspace
3.8.5. resource list Copy linkLink copied to clipboard!
List Pipeline Resources.
Example: List all Pipeline Resources in a namespace
tkn resource list -n myspace
$ tkn resource list -n myspace
3.9. Trigger management commands Copy linkLink copied to clipboard!
3.9.1. eventlistener Copy linkLink copied to clipboard!
Manage EventListeners.
Example: Display help
tkn eventlistener -h
$ tkn eventlistener -h
3.9.2. eventlistener delete Copy linkLink copied to clipboard!
Delete an EventListener.
Example: Delete mylistener1
and mylistener2
EventListeners in a namespace
tkn eventlistener delete mylistener1 mylistener2 -n myspace
$ tkn eventlistener delete mylistener1 mylistener2 -n myspace
3.9.3. eventlistener describe Copy linkLink copied to clipboard!
Describe an EventListener.
Example: Describe the mylistener
EventListener in a namespace
tkn eventlistener describe mylistener -n myspace
$ tkn eventlistener describe mylistener -n myspace
3.9.4. eventlistener list Copy linkLink copied to clipboard!
List EventListeners.
Example: List all the EventListeners in a namespace
tkn eventlistener list -n myspace
$ tkn eventlistener list -n myspace
3.9.5. eventlistener logs Copy linkLink copied to clipboard!
Display logs of an EventListener.
Example: Display the logs of the mylistener
EventListener in a namespace
tkn eventlistener logs mylistener -n myspace
$ tkn eventlistener logs mylistener -n myspace
3.9.6. triggerbinding Copy linkLink copied to clipboard!
Manage TriggerBindings.
Example: Display TriggerBindings help
tkn triggerbinding -h
$ tkn triggerbinding -h
3.9.7. triggerbinding delete Copy linkLink copied to clipboard!
Delete a TriggerBinding.
Example: Delete mybinding1
and mybinding2
TriggerBindings in a namespace
tkn triggerbinding delete mybinding1 mybinding2 -n myspace
$ tkn triggerbinding delete mybinding1 mybinding2 -n myspace
3.9.8. triggerbinding describe Copy linkLink copied to clipboard!
Describe a TriggerBinding.
Example: Describe the mybinding
TriggerBinding in a namespace
tkn triggerbinding describe mybinding -n myspace
$ tkn triggerbinding describe mybinding -n myspace
3.9.9. triggerbinding list Copy linkLink copied to clipboard!
List TriggerBindings.
Example: List all the TriggerBindings in a namespace
tkn triggerbinding list -n myspace
$ tkn triggerbinding list -n myspace
3.9.10. triggertemplate Copy linkLink copied to clipboard!
Manage TriggerTemplates.
Example: Display TriggerTemplate help
tkn triggertemplate -h
$ tkn triggertemplate -h
3.9.11. triggertemplate delete Copy linkLink copied to clipboard!
Delete a TriggerTemplate.
Example: Delete mytemplate1
and mytemplate2
TriggerTemplates in a namespace
tkn triggertemplate delete mytemplate1 mytemplate2 -n `myspace`
$ tkn triggertemplate delete mytemplate1 mytemplate2 -n `myspace`
3.9.12. triggertemplate describe Copy linkLink copied to clipboard!
Describe a TriggerTemplate.
Example: Describe the mytemplate
TriggerTemplate in a namespace
tkn triggertemplate describe mytemplate -n `myspace`
$ tkn triggertemplate describe mytemplate -n `myspace`
3.9.13. triggertemplate list Copy linkLink copied to clipboard!
List TriggerTemplates.
Example: List all the TriggerTemplates in a namespace
tkn triggertemplate list -n myspace
$ tkn triggertemplate list -n myspace
3.9.14. clustertriggerbinding Copy linkLink copied to clipboard!
Manage ClusterTriggerBindings.
Example: Display ClusterTriggerBindings help
tkn clustertriggerbinding -h
$ tkn clustertriggerbinding -h
3.9.15. clustertriggerbinding delete Copy linkLink copied to clipboard!
Delete a ClusterTriggerBinding.
Example: Delete myclusterbinding1
and myclusterbinding2
ClusterTriggerBindings
tkn clustertriggerbinding delete myclusterbinding1 myclusterbinding2
$ tkn clustertriggerbinding delete myclusterbinding1 myclusterbinding2
3.9.16. clustertriggerbinding describe Copy linkLink copied to clipboard!
Describe a ClusterTriggerBinding.
Example: Describe the myclusterbinding
ClusterTriggerBinding
tkn clustertriggerbinding describe myclusterbinding
$ tkn clustertriggerbinding describe myclusterbinding
3.9.17. clustertriggerbinding list Copy linkLink copied to clipboard!
List ClusterTriggerBindings.
Example: List all ClusterTriggerBindings
tkn clustertriggerbinding list
$ tkn clustertriggerbinding list
3.10. Hub interaction commands Copy linkLink copied to clipboard!
Interact with Tekton Hub for resources such as tasks and pipelines.
3.10.1. hub Copy linkLink copied to clipboard!
Interact with hub.
Example: Display help
tkn hub -h
$ tkn hub -h
Example: Interact with a hub API server
tkn hub --api-server https://api.hub.tekton.dev
$ tkn hub --api-server https://api.hub.tekton.dev
For each example, to get the corresponding sub-commands and flags, run tkn hub <command> --help
.
3.10.2. hub downgrade Copy linkLink copied to clipboard!
Downgrade an installed resource.
Example: Downgrade the mytask
task in the mynamespace
namespace to it’s older version
tkn hub downgrade task mytask --to version -n mynamespace
$ tkn hub downgrade task mytask --to version -n mynamespace
3.10.3. hub get Copy linkLink copied to clipboard!
Get a resource manifest by its name, kind, catalog, and version.
Example: Get the manifest for a specific version of the myresource
pipeline or task from the tekton
catalog
tkn hub get [pipeline | task] myresource --from tekton --version version
$ tkn hub get [pipeline | task] myresource --from tekton --version version
3.10.4. hub info Copy linkLink copied to clipboard!
Display information about a resource by its name, kind, catalog, and version.
Example: Display information about a specific version of the mytask
task from the tekton
catalog
tkn hub info task mytask --from tekton --version version
$ tkn hub info task mytask --from tekton --version version
3.10.5. hub install Copy linkLink copied to clipboard!
Install a resource from a catalog by its kind, name, and version.
Example: Install a specific version of the mytask
task from the tekton
catalog in the mynamespace
namespace
tkn hub install task mytask --from tekton --version version -n mynamespace
$ tkn hub install task mytask --from tekton --version version -n mynamespace
3.10.6. hub reinstall Copy linkLink copied to clipboard!
Reinstall a resource by its kind and name.
Example: Reinstall a specific version of the mytask
task from the tekton
catalog in the mynamespace
namespace
tkn hub reinstall task mytask --from tekton --version version -n mynamespace
$ tkn hub reinstall task mytask --from tekton --version version -n mynamespace
3.10.7. hub search Copy linkLink copied to clipboard!
Search a resource by a combination of name, kind, and tags.
Example: Search a resource with a tag cli
tkn hub search --tags cli
$ tkn hub search --tags cli
3.10.8. hub upgrade Copy linkLink copied to clipboard!
Upgrade an installed resource.
Example: Upgrade the installed mytask
task in the mynamespace
namespace to a new version
tkn hub upgrade task mytask --to version -n mynamespace
$ tkn hub upgrade task mytask --to version -n mynamespace