OpenShift Pipelines As Code 😻
This article introduces PipelinesAsCode and how one can integrate it with their project.
> Update: this article was based on Pipelines As Code 0.5.3 which is quite old, we have done many new releases with the new features, and an updated blog is coming soon. Please Checkout https://pipelinesascode.com/ for documentation.
New Blog : https://sm43.medium.com/openshift-tekton-pipelines-as-code-v2-bb356ee66010
What is Pipelines as Code?
An opinionated CI based on OpenShift Pipelines / Tekton.
PipelinesAsCode is like an agent which runs your CI Tekton Pipelines on a Kubernetes cluster and reports status back to your repository.
If you wanna know what Tekton is then you can find it in
Features:
- Pull-request status supported
Configure your repository with PipelinesAsCode and you can get the CI pipeline status on your pull request after completion - Re-trigger the pipeline from pull request
- Keep your CI pipeline in your repository and pipleinesAsCode handles the rest
- You can refer Tekton Tasks from the Tekton Hub and PipelinesAsCode will resolve them
tkn-pac
plugin for Tekton CLI for managing pipelines-as-code repositories and bootstrapping- Bitbucket Server, Bitbucket Cloud and Github Webhook support
- ACL over a GitHub organization or via a Prow style
OWNER
file.
and many more… check it out on the repository.
# Prerequisites
- Kubernetes Cluster
I will be using an OpenShift cluster but any you can follow with any K8s cluster. - tkn pac CLI
You can get it from the release page here.
# Installation
Make sure Tekton / OpenShift Pipelines is installed on the cluster.
To install PipelinesAsCode, we can just use tkn-pac CLI.
NOTE: At the time of writing this article, the latest released version is v0.5.3
and if you are on OpenShift, then PipelinesAsCode will be available with OpenShift Pipelines in v1.7.
If you have tkn
on your machine then tkn-pac
works as an extension to tkn
. You can execute tkn-pac command as
tkn pac bootstrap
if you don’t have tkn then
tkn-pac bootstrap

This would
- install pipleinesAsCode on the cluster in pipelines-as-code namespace
- As this is an OpenShift cluster, it will also create a route to configure with GitHub Application
- It creates a GitHub application which would send events from the repository to PipelinesAsCode
Now, the next steps would be
- installing the GitHub application on the repository we want to use
- registering that repostitory with PipelinesAsCode by creating Repository Object on the cluster
Firstly, lets create a new repo and configure the application

You can install the app directly on you existing repositories.
Next step would be to register the repository. Clone your repository and execute the tkn pac repo new
.

This would
- create repository object by taking default values from you local repo
- it also creates a sample PipelineRun template in .tekton directory
You can update this template depending on your project. This is the pipelineRun which would be executed against your project.
You can mention the Tasks you want to use in Pipeline in the annotation of PipelineRun and PipelineAsCode will fetch and install it for you.
For example:
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: pipeline-as-code-on-pull-request
annotations:
pipelinesascode.tekton.dev/on-event: "[pull_request]"
pipelinesascode.tekton.dev/on-target-branch: "[main]"
pipelinesascode.tekton.dev/task: "[git-clone]"
pipelinesascode.tekton.dev/max-keep-runs: "2"
spec:
You can refer PipelinesAsCode docs and the example here.
Once you update the PipelineRun, commit your changes and create a pull request which would execute the PipelineRun on the cluster.

We can see here that pipelineRun defined in .tekton directory is executed against the repository and status is reported back on the pull request.
You can find more information on the PipelinesAsCode Repository https://github.com/openshift-pipelines/pipelines-as-code.
You can go through the docs here or create an issue for any questions.
Thanks for reading.. feedback is welcome 😃.