Chapter 6. Pipelines CLI (tkn)
Chapter 6. Pipelines CLI (tkn) 6.1. Installing tkn 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 For Linux distributions, you can download the CLI directly as a tar.gz archive. Procedure Download the relevant CLI. Linux (x86_64, amd64) Linux on IBM Z and LinuxONE (s390x) Linux on IBM Power Systems (ppc64le) Unpack the archive: USD tar xvzf <file> Place the tkn binary in a directory that is on your PATH . To check your PATH , run: USD echo USDPATH 6.1.2. Installing Red Hat OpenShift Pipelines CLI (tkn) on Linux using an RPM 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 register Pull the latest subscription data: # subscription-manager refresh List the available subscriptions: # subscription-manager list --available --matches '*pipelines*' In the output for the 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: Linux (x86_64, amd64) # subscription-manager repos --enable="pipelines-1.4-for-rhel-8-x86_64-rpms" Linux on IBM Z and LinuxONE (s390x) # subscription-manager repos --enable="pipelines-1.4-for-rhel-8-s390x-rpms" Linux on IBM Power Systems (ppc64le) # subscription-manager repos --enable="pipelines-1.4-for-rhel-8-ppc64le-rpms" Install the openshift-pipelines-client package: # yum install openshift-pipelines-client After you install the CLI, it is available using the tkn command: USD tkn version 6.1.3. Installing Red Hat OpenShift Pipelines CLI (tkn) on Windows 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.exe file to your PATH environment 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 For macOS, the tkn CLI is provided as a tar.gz archive. Procedure Download the CLI . Unpack and unzip the archive. Move the tkn binary to a directory on your PATH. To check your PATH , open a terminal window and run: USD echo USDPATH 6.2. Configuring the OpenShift Pipelines tkn CLI Configure the Red Hat OpenShift Pipelines tkn CLI to enable tab completion. 6.2.1. Enabling tab completion 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: USD tkn completion bash > tkn_bash_completion Copy the file to /etc/bash_completion.d/ : USD sudo cp tkn_bash_completion /etc/bash_completion.d/ 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. 6.3. OpenShift Pipelines tkn reference This section lists the basic tkn CLI commands. 6.3.1. Basic syntax tkn [command or options] [arguments... ] 6.3.2. Global options --help, -h 6.3.3. Utility commands 6.3.3.1. tkn Parent command for tkn CLI. Example: Display all options USD tkn 6.3.3.2. completion [shell] Print shell completion code which must be evaluated to provide interactive completion. Supported shells are bash and zsh . Example: Completion code for bash shell USD tkn completion bash 6.3.3.3. version Print version information of the tkn CLI. Example: Check the tkn version USD tkn version 6.3.4. Pipelines management commands 6.3.4.1. pipeline Manage Pipelines. Example: Display help USD tkn pipeline --help 6.3.4.2. pipeline delete Delete a Pipeline. Example: Delete the mypipeline Pipeline from a namespace USD tkn pipeline delete mypipeline -n myspace 6.3.4.3. pipeline describe Describe a Pipeline. Example: Describe mypipeline Pipeline USD tkn pipeline describe mypipeline 6.3.4.4. pipeline list List Pipelines. Example: Display a list of Pipelines USD tkn pipeline list 6.3.4.5. pipeline logs Display Pipeline logs for a specific Pipeline. Example: Stream live logs for the mypipeline Pipeline USD tkn pipeline logs -f mypipeline 6.3.4.6. pipeline start Start a Pipeline. Example: Start mypipeline Pipeline USD tkn pipeline start mypipeline 6.3.5. PipelineRun commands 6.3.5.1. pipelinerun Manage PipelineRuns. Example: Display help USD tkn pipelinerun -h 6.3.5.2. pipelinerun cancel Cancel a PipelineRun. Example: Cancel the mypipelinerun PipelineRun from a namespace USD tkn pipelinerun cancel mypipelinerun -n myspace 6.3.5.3. pipelinerun delete Delete a PipelineRun. Example: Delete PipelineRuns from a namespace USD tkn pipelinerun delete mypipelinerun1 mypipelinerun2 -n myspace 6.3.5.4. pipelinerun describe Describe a PipelineRun. Example: Describe the mypipelinerun PipelineRun in a namespace USD tkn pipelinerun describe mypipelinerun -n myspace 6.3.5.5. pipelinerun list List PipelineRuns. Example: Display a list of PipelineRuns in a namespace USD tkn pipelinerun list -n myspace 6.3.5.6. pipelinerun logs Display the logs of a PipelineRun. Example: Display the logs of the mypipelinerun PipelineRun with all tasks and steps in a namespace USD tkn pipelinerun logs mypipelinerun -a -n myspace 6.3.6. Task management commands 6.3.6.1. task Manage Tasks. Example: Display help USD tkn task -h 6.3.6.2. task delete Delete a Task. Example: Delete mytask1 and mytask2 Tasks from a namespace USD tkn task delete mytask1 mytask2 -n myspace 6.3.6.3. task describe Describe a Task. Example: Describe the mytask Task in a namespace USD tkn task describe mytask -n myspace 6.3.6.4. task list List Tasks. Example: List all the Tasks in a namespace USD tkn task list -n myspace 6.3.6.5. task logs Display Task logs. Example: Display logs for the mytaskrun TaskRun of the mytask Task USD tkn task logs mytask mytaskrun -n myspace 6.3.6.6. task start Start a Task. Example: Start the mytask Task in a namespace USD tkn task start mytask -s <ServiceAccountName> -n myspace 6.3.7. TaskRun commands 6.3.7.1. taskrun Manage TaskRuns. Example: Display help USD tkn taskrun -h 6.3.7.2. taskrun cancel Cancel a TaskRun. Example: Cancel the mytaskrun TaskRun from a namespace USD tkn taskrun cancel mytaskrun -n myspace 6.3.7.3. taskrun delete Delete a TaskRun. Example: Delete mytaskrun1 and mytaskrun2 TaskRuns from a namespace USD tkn taskrun delete mytaskrun1 mytaskrun2 -n myspace 6.3.7.4. taskrun describe Describe a TaskRun. Example: Describe the mytaskrun TaskRun in a namespace USD tkn taskrun describe mytaskrun -n myspace 6.3.7.5. taskrun list List TaskRuns. Example: List all TaskRuns in a namespace USD tkn taskrun list -n myspace 6.3.7.6. taskrun logs Display TaskRun logs. Example: Display live logs for the mytaskrun TaskRun in a namespace USD tkn taskrun logs -f mytaskrun -n myspace 6.3.8. Condition management commands 6.3.8.1. condition Manage Conditions. Example: Display help USD tkn condition --help 6.3.8.2. condition delete Delete a Condition. Example: Delete the mycondition1 Condition from a namespace USD tkn condition delete mycondition1 -n myspace 6.3.8.3. condition describe Describe a Condition. Example: Describe the mycondition1 Condition in a namespace USD tkn condition describe mycondition1 -n myspace 6.3.8.4. condition list List Conditions. Example: List Conditions in a namespace USD tkn condition list -n myspace 6.3.9. Pipeline Resource management commands 6.3.9.1. resource Manage Pipeline Resources. Example: Display help USD tkn resource -h 6.3.9.2. resource create Create a Pipeline Resource. Example: Create a Pipeline Resource in a namespace USD 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 Delete a Pipeline Resource. Example: Delete the myresource Pipeline Resource from a namespace USD tkn resource delete myresource -n myspace 6.3.9.4. resource describe Describe a Pipeline Resource. Example: Describe the myresource Pipeline Resource USD tkn resource describe myresource -n myspace 6.3.9.5. resource list List Pipeline Resources. Example: List all Pipeline Resources in a namespace USD tkn resource list -n myspace 6.3.10. ClusterTask management commands 6.3.10.1. clustertask Manage ClusterTasks. Example: Display help USD tkn clustertask --help 6.3.10.2. clustertask delete Delete a ClusterTask resource in a cluster. Example: Delete mytask1 and mytask2 ClusterTasks USD tkn clustertask delete mytask1 mytask2 6.3.10.3. clustertask describe Describe a ClusterTask. Example: Describe the mytask ClusterTask USD tkn clustertask describe mytask1 6.3.10.4. clustertask list List ClusterTasks. Example: List ClusterTasks USD tkn clustertask list 6.3.10.5. clustertask start Start ClusterTasks. Example: Start the mytask ClusterTask USD tkn clustertask start mytask 6.3.11. Trigger management commands 6.3.11.1. eventlistener Manage EventListeners. Example: Display help USD tkn eventlistener -h 6.3.11.2. eventlistener delete Delete an EventListener. Example: Delete mylistener1 and mylistener2 EventListeners in a namespace USD tkn eventlistener delete mylistener1 mylistener2 -n myspace 6.3.11.3. eventlistener describe Describe an EventListener. Example: Describe the mylistener EventListener in a namespace USD tkn eventlistener describe mylistener -n myspace 6.3.11.4. eventlistener list List EventListeners. Example: List all the EventListeners in a namespace USD tkn eventlistener list -n myspace 6.3.11.5. eventlistener logs Display logs of an EventListener. Example: Display the logs of the mylistener EventListener in a namespace USD tkn eventlistener logs mylistener -n myspace 6.3.11.6. triggerbinding Manage TriggerBindings. Example: Display TriggerBindings help USD tkn triggerbinding -h 6.3.11.7. triggerbinding delete Delete a TriggerBinding. Example: Delete mybinding1 and mybinding2 TriggerBindings in a namespace USD tkn triggerbinding delete mybinding1 mybinding2 -n myspace 6.3.11.8. triggerbinding describe Describe a TriggerBinding. Example: Describe the mybinding TriggerBinding in a namespace USD tkn triggerbinding describe mybinding -n myspace 6.3.11.9. triggerbinding list List TriggerBindings. Example: List all the TriggerBindings in a namespace USD tkn triggerbinding list -n myspace 6.3.11.10. triggertemplate Manage TriggerTemplates. Example: Display TriggerTemplate help USD tkn triggertemplate -h 6.3.11.11. triggertemplate delete Delete a TriggerTemplate. Example: Delete mytemplate1 and mytemplate2 TriggerTemplates in a namespace USD tkn triggertemplate delete mytemplate1 mytemplate2 -n `myspace` 6.3.11.12. triggertemplate describe Describe a TriggerTemplate. Example: Describe the mytemplate TriggerTemplate in a namespace USD tkn triggertemplate describe mytemplate -n `myspace` 6.3.11.13. triggertemplate list List TriggerTemplates. Example: List all the TriggerTemplates in a namespace USD tkn triggertemplate list -n myspace 6.3.11.14. clustertriggerbinding Manage ClusterTriggerBindings. Example: Display ClusterTriggerBindings help USD tkn clustertriggerbinding -h 6.3.11.15. clustertriggerbinding delete Delete a ClusterTriggerBinding. Example: Delete myclusterbinding1 and myclusterbinding2 ClusterTriggerBindings USD tkn clustertriggerbinding delete myclusterbinding1 myclusterbinding2 6.3.11.16. clustertriggerbinding describe Describe a ClusterTriggerBinding. Example: Describe the myclusterbinding ClusterTriggerBinding USD tkn clustertriggerbinding describe myclusterbinding 6.3.11.17. clustertriggerbinding list List ClusterTriggerBindings. Example: List all ClusterTriggerBindings USD tkn clustertriggerbinding list 6.3.12. Hub interaction commands Interact with Tekton Hub for resources such as tasks and pipelines. 6.3.12.1. hub Interact with hub. Example: Display help USD tkn hub -h Example: Interact with a hub API server USD tkn hub --api-server https://api.hub.tekton.dev Note For each example, to get the corresponding sub-commands and flags, run tkn hub <command> --help . 6.3.12.2. hub downgrade Downgrade an installed resource. Example: Downgrade the mytask task in the mynamespace namespace to it's older version USD tkn hub downgrade task mytask --to version -n mynamespace 6.3.12.3. hub get 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 USD tkn hub get [pipeline | task] myresource --from tekton --version version 6.3.12.4. hub info 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 USD tkn hub info task mytask --from tekton --version version 6.3.12.5. hub install 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 USD tkn hub install task mytask --from tekton --version version -n mynamespace 6.3.12.6. hub reinstall 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 USD tkn hub reinstall task mytask --from tekton --version version -n mynamespace 6.3.12.7. hub search Search a resource by a combination of name, kind, and tags. Example: Search a resource with a tag cli USD tkn hub search --tags cli 6.3.12.8. hub upgrade Upgrade an installed resource. Example: Upgrade the installed mytask task in the mynamespace namespace to a new version USD tkn hub upgrade task mytask --to version -n mynamespace
tar xvzf <file> echo USDPATH subscription-manager register subscription-manager refresh subscription-manager list --available --matches '*pipelines*' subscription-manager attach --pool=<pool_id> subscription-manager repos --enable="pipelines-1.4-for-rhel-8-x86_64-rpms" subscription-manager repos --enable="pipelines-1.4-for-rhel-8-s390x-rpms" subscription-manager repos --enable="pipelines-1.4-for-rhel-8-ppc64le-rpms" yum install openshift-pipelines-client tkn version C:\> path echo USDPATH tkn completion bash > tkn_bash_completion sudo cp tkn_bash_completion /etc/bash_completion.d/ tkn tkn completion bash tkn version tkn pipeline --help tkn pipeline delete mypipeline -n myspace tkn pipeline describe mypipeline tkn pipeline list tkn pipeline logs -f mypipeline tkn pipeline start mypipeline tkn pipelinerun -h tkn pipelinerun cancel mypipelinerun -n myspace tkn pipelinerun delete mypipelinerun1 mypipelinerun2 -n myspace tkn pipelinerun describe mypipelinerun -n myspace tkn pipelinerun list -n myspace tkn pipelinerun logs mypipelinerun -a -n myspace tkn task -h tkn task delete mytask1 mytask2 -n myspace tkn task describe mytask -n myspace tkn task list -n myspace tkn task logs mytask mytaskrun -n myspace tkn task start mytask -s <ServiceAccountName> -n myspace tkn taskrun -h tkn taskrun cancel mytaskrun -n myspace tkn taskrun delete mytaskrun1 mytaskrun2 -n myspace tkn taskrun describe mytaskrun -n myspace tkn taskrun list -n myspace tkn taskrun logs -f mytaskrun -n myspace tkn condition --help tkn condition delete mycondition1 -n myspace tkn condition describe mycondition1 -n myspace tkn condition list -n myspace tkn resource -h tkn resource create -n myspace tkn resource delete myresource -n myspace tkn resource describe myresource -n myspace tkn resource list -n myspace tkn clustertask --help tkn clustertask delete mytask1 mytask2 tkn clustertask describe mytask1 tkn clustertask list tkn clustertask start mytask tkn eventlistener -h tkn eventlistener delete mylistener1 mylistener2 -n myspace tkn eventlistener describe mylistener -n myspace tkn eventlistener list -n myspace tkn eventlistener logs mylistener -n myspace tkn triggerbinding -h tkn triggerbinding delete mybinding1 mybinding2 -n myspace tkn triggerbinding describe mybinding -n myspace tkn triggerbinding list -n myspace tkn triggertemplate -h tkn triggertemplate delete mytemplate1 mytemplate2 -n `myspace` tkn triggertemplate describe mytemplate -n `myspace` tkn triggertemplate list -n myspace tkn clustertriggerbinding -h tkn clustertriggerbinding delete myclusterbinding1 myclusterbinding2 tkn clustertriggerbinding describe myclusterbinding tkn clustertriggerbinding list tkn hub -h tkn hub --api-server https://api.hub.tekton.dev tkn hub downgrade task mytask --to version -n mynamespace tkn hub get [pipeline | task] myresource --from tekton --version version tkn hub info task mytask --from tekton --version version tkn hub install task mytask --from tekton --version version -n mynamespace tkn hub reinstall task mytask --from tekton --version version -n mynamespace tkn hub search --tags cli tkn hub upgrade task mytask --to version -n mynamespace