Chapter 6. Pipelines CLI (tkn)
6.1. Installing tkn Copy linkLink copied to clipboard!
Use the tkn CLI to manage Red Hat OpenShift Pipelines from a terminal. The following section describes how to install tkn on different platforms.
You can also find the URL to the latest binaries from the OpenShift Container Platform web console by clicking the ? icon in the upper-right corner and selecting Command Line Tools.
6.1.1. Installing Red Hat OpenShift Pipelines CLI (tkn) on Linux Copy linkLink copied to clipboard!
For Linux distributions, you can download the CLI directly as a tar.gz archive.
Procedure
Download the relevant CLI.
Unpack the archive:
$ tar xvzf <file>-
Place the
tknbinary in a directory that is on yourPATH. To check your
PATH, run:$ echo $PATH
6.1.2. Installing Red Hat OpenShift Pipelines CLI (tkn) 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 (tkn) 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 registerPull the latest subscription data:
# subscription-manager refreshList the available subscriptions:
# subscription-manager list --available --matches '*pipelines*'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>Enable the repositories required by Red Hat OpenShift Pipelines:
# subscription-manager repos --enable="pipelines-1.2-for-rhel-8-x86_64-rpms"Install the
openshift-pipelines-clientpackage:# yum install openshift-pipelines-client
After you install the CLI, it is available using the tkn command:
$ tkn version
6.1.3. Installing Red Hat OpenShift Pipelines CLI (tkn) on Windows Copy linkLink copied to clipboard!
For Windows, the tkn CLI is provided as a zip archive.
Procedure
- Download the CLI.
- Unzip the archive with a ZIP program.
-
Add the location of your
tkn.exefile to yourPATHenvironment variable. To check your
PATH, open the command prompt and run the command:C:\> path
6.1.4. Installing Red Hat OpenShift Pipelines CLI (tkn) on macOS Copy linkLink copied to clipboard!
For macOS, the tkn CLI is provided as a tar.gz archive.
Procedure
- Download the CLI.
- Unpack and unzip the archive.
-
Move the
tknbinary to a directory on your PATH. To check your
PATH, open a terminal window and run:$ echo $PATH
6.2. Configuring the OpenShift Pipelines tkn CLI Copy linkLink copied to clipboard!
Configure the Red Hat OpenShift Pipelines tkn CLI to enable tab completion.
6.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
tknCLI tool installed. -
You must have
bash-completioninstalled 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_completionCopy the file to
/etc/bash_completion.d/:$ sudo cp tkn_bash_completion /etc/bash_completion.d/Alternatively, you can save the file to a local directory and source it from your
.bashrcfile instead.
Tab completion is enabled when you open a new terminal.
6.3. OpenShift Pipelines tkn reference Copy linkLink copied to clipboard!
This section lists the basic tkn CLI commands.
6.3.1. Basic syntax Copy linkLink copied to clipboard!
tkn [command or options] [arguments…]
6.3.2. Global options Copy linkLink copied to clipboard!
--help, -h
6.3.3. Utility commands Copy linkLink copied to clipboard!
6.3.3.1. tkn Copy linkLink copied to clipboard!
Parent command for tkn CLI.
Example: Display all options
$ tkn
6.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
6.3.3.3. version Copy linkLink copied to clipboard!
Print version information of the tkn CLI.
Example: Check the tkn version
$ tkn version
6.3.4. Pipelines management commands Copy linkLink copied to clipboard!
6.3.4.1. pipeline Copy linkLink copied to clipboard!
Manage Pipelines.
Example: Display help
$ tkn pipeline --help
6.3.4.2. pipeline delete Copy linkLink copied to clipboard!
Delete a Pipeline.
Example: Delete the mypipeline Pipeline from a namespace
$ tkn pipeline delete mypipeline -n myspace
6.3.4.3. pipeline describe Copy linkLink copied to clipboard!
Describe a Pipeline.
Example: Describe mypipeline Pipeline
$ tkn pipeline describe mypipeline
6.3.4.4. pipeline list Copy linkLink copied to clipboard!
List Pipelines.
Example: Display a list of Pipelines
$ tkn pipeline list
6.3.4.5. pipeline logs Copy linkLink copied to clipboard!
Display Pipeline logs for a specific Pipeline.
Example: Stream live logs for the mypipeline Pipeline
$ tkn pipeline logs -f mypipeline
6.3.4.6. pipeline start Copy linkLink copied to clipboard!
Start a Pipeline.
Example: Start mypipeline Pipeline
$ tkn pipeline start mypipeline
6.3.5. PipelineRun commands Copy linkLink copied to clipboard!
6.3.5.1. pipelinerun Copy linkLink copied to clipboard!
Manage PipelineRuns.
Example: Display help
$ tkn pipelinerun -h
6.3.5.2. pipelinerun cancel Copy linkLink copied to clipboard!
Cancel a PipelineRun.
Example: Cancel the mypipelinerun PipelineRun from a namespace
$ tkn pipelinerun cancel mypipelinerun -n myspace
6.3.5.3. pipelinerun delete Copy linkLink copied to clipboard!
Delete a PipelineRun.
Example: Delete PipelineRuns from a namespace
$ tkn pipelinerun delete mypipelinerun1 mypipelinerun2 -n myspace
6.3.5.4. pipelinerun describe Copy linkLink copied to clipboard!
Describe a PipelineRun.
Example: Describe the mypipelinerun PipelineRun in a namespace
$ tkn pipelinerun describe mypipelinerun -n myspace
6.3.5.5. pipelinerun list Copy linkLink copied to clipboard!
List PipelineRuns.
Example: Display a list of PipelineRuns in a namespace
$ tkn pipelinerun list -n myspace
6.3.5.6. pipelinerun logs Copy linkLink copied to clipboard!
Display the logs of a PipelineRun.
Example: Display the logs of the mypipelinerun PipelineRun with all tasks and steps in a namespace
$ tkn pipelinerun logs mypipelinerun -a -n myspace
6.3.6. Task management commands Copy linkLink copied to clipboard!
6.3.6.1. task Copy linkLink copied to clipboard!
Manage Tasks.
Example: Display help
$ tkn task -h
6.3.6.2. task delete Copy linkLink copied to clipboard!
Delete a Task.
Example: Delete mytask1 and mytask2 Tasks from a namespace
$ tkn task delete mytask1 mytask2 -n myspace
6.3.6.3. task describe Copy linkLink copied to clipboard!
Describe a Task.
Example: Describe the mytask Task in a namespace
$ tkn task describe mytask -n myspace
6.3.6.4. task list Copy linkLink copied to clipboard!
List Tasks.
Example: List all the Tasks in a namespace
$ tkn task list -n myspace
6.3.6.5. task logs Copy linkLink copied to clipboard!
Display Task logs.
Example: Display logs for the mytaskrun TaskRun of the mytask Task
$ tkn task logs mytask mytaskrun -n myspace
6.3.6.6. task start Copy linkLink copied to clipboard!
Start a Task.
Example: Start the mytask Task in a namespace
$ tkn task start mytask -s <ServiceAccountName> -n myspace
6.3.7. TaskRun commands Copy linkLink copied to clipboard!
6.3.7.1. taskrun Copy linkLink copied to clipboard!
Manage TaskRuns.
Example: Display help
$ tkn taskrun -h
6.3.7.2. taskrun cancel Copy linkLink copied to clipboard!
Cancel a TaskRun.
Example: Cancel the mytaskrun TaskRun from a namespace
$ tkn taskrun cancel mytaskrun -n myspace
6.3.7.3. taskrun delete Copy linkLink copied to clipboard!
Delete a TaskRun.
Example: Delete mytaskrun1 and mytaskrun2 TaskRuns from a namespace
$ tkn taskrun delete mytaskrun1 mytaskrun2 -n myspace
6.3.7.4. taskrun describe Copy linkLink copied to clipboard!
Describe a TaskRun.
Example: Describe the mytaskrun TaskRun in a namespace
$ tkn taskrun describe mytaskrun -n myspace
6.3.7.5. taskrun list Copy linkLink copied to clipboard!
List TaskRuns.
Example: List all TaskRuns in a namespace
$ tkn taskrun list -n myspace
6.3.7.6. taskrun logs Copy linkLink copied to clipboard!
Display TaskRun logs.
Example: Display live logs for the mytaskrun TaskRun in a namespace
$ tkn taskrun logs -f mytaskrun -n myspace
6.3.8. Condition management commands Copy linkLink copied to clipboard!
6.3.8.1. condition Copy linkLink copied to clipboard!
Manage Conditions.
Example: Display help
$ tkn condition --help
6.3.8.2. condition delete Copy linkLink copied to clipboard!
Delete a Condition.
Example: Delete the mycondition1 Condition from a namespace
$ tkn condition delete mycondition1 -n myspace
6.3.8.3. condition describe Copy linkLink copied to clipboard!
Describe a Condition.
Example: Describe the mycondition1 Condition in a namespace
$ tkn condition describe mycondition1 -n myspace
6.3.8.4. condition list Copy linkLink copied to clipboard!
List Conditions.
Example: List Conditions in a namespace
$ tkn condition list -n myspace
6.3.9. Pipeline Resource management commands Copy linkLink copied to clipboard!
6.3.9.1. resource Copy linkLink copied to clipboard!
Manage Pipeline Resources.
Example: Display help
$ tkn resource -h
6.3.9.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
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.
6.3.9.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
6.3.9.4. resource describe Copy linkLink copied to clipboard!
Describe a Pipeline Resource.
Example: Describe the myresource Pipeline Resource
$ tkn resource describe myresource -n myspace
6.3.9.5. resource list Copy linkLink copied to clipboard!
List Pipeline Resources.
Example: List all Pipeline Resources in a namespace
$ tkn resource list -n myspace
6.3.10. ClusterTask management commands Copy linkLink copied to clipboard!
6.3.10.1. clustertask Copy linkLink copied to clipboard!
Manage ClusterTasks.
Example: Display help
$ tkn clustertask --help
6.3.10.2. clustertask delete Copy linkLink copied to clipboard!
Delete a ClusterTask resource in a cluster.
Example: Delete mytask1 and mytask2 ClusterTasks
$ tkn clustertask delete mytask1 mytask2
6.3.10.3. clustertask describe Copy linkLink copied to clipboard!
Describe a ClusterTask.
Example: Describe the mytask ClusterTask
$ tkn clustertask describe mytask1
6.3.10.4. clustertask list Copy linkLink copied to clipboard!
List ClusterTasks.
Example: List ClusterTasks
$ tkn clustertask list
6.3.10.5. clustertask start Copy linkLink copied to clipboard!
Start ClusterTasks.
Example: Start the mytask ClusterTask
$ tkn clustertask start mytask
6.3.11. Trigger management commands Copy linkLink copied to clipboard!
6.3.11.1. eventlistener Copy linkLink copied to clipboard!
Manage EventListeners.
Example: Display help
$ tkn eventlistener -h
6.3.11.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
6.3.11.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
6.3.11.4. eventlistener list Copy linkLink copied to clipboard!
List EventListeners.
Example: List all the EventListeners in a namespace
$ tkn eventlistener list -n myspace
6.3.11.5. triggerbinding Copy linkLink copied to clipboard!
Manage TriggerBindings.
Example: Display TriggerBindings help
$ tkn triggerbinding -h
6.3.11.6. 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
6.3.11.7. triggerbinding describe Copy linkLink copied to clipboard!
Describe a TriggerBinding.
Example: Describe the mybinding TriggerBinding in a namespace
$ tkn triggerbinding describe mybinding -n myspace
6.3.11.8. triggerbinding list Copy linkLink copied to clipboard!
List TriggerBindings.
Example: List all the TriggerBindings in a namespace
$ tkn triggerbinding list -n myspace
6.3.11.9. triggertemplate Copy linkLink copied to clipboard!
Manage TriggerTemplates.
Example: Display TriggerTemplate help
$ tkn triggertemplate -h
6.3.11.10. 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`
6.3.11.11. triggertemplate describe Copy linkLink copied to clipboard!
Describe a TriggerTemplate.
Example: Describe the mytemplate TriggerTemplate in a namespace
$ tkn triggertemplate describe mytemplate -n `myspace`
6.3.11.12. triggertemplate list Copy linkLink copied to clipboard!
List TriggerTemplates.
Example: List all the TriggerTemplates in a namespace
$ tkn triggertemplate list -n myspace
6.3.11.13. clustertriggerbinding Copy linkLink copied to clipboard!
Manage ClusterTriggerBindings.
Example: Display ClusterTriggerBindings help
$ tkn clustertriggerbinding -h
6.3.11.14. clustertriggerbinding delete Copy linkLink copied to clipboard!
Delete a ClusterTriggerBinding.
Example: Delete myclusterbinding1 and myclusterbinding2 ClusterTriggerBindings
$ tkn clustertriggerbinding delete myclusterbinding1 myclusterbinding2
6.3.11.15. clustertriggerbinding describe Copy linkLink copied to clipboard!
Describe a ClusterTriggerBinding.
Example: Describe the myclusterbinding ClusterTriggerBinding
$ tkn clustertriggerbinding describe myclusterbinding
6.3.11.16. clustertriggerbinding list Copy linkLink copied to clipboard!
List ClusterTriggerBindings.
Example: List all ClusterTriggerBindings
$ tkn clustertriggerbinding list