Trigger Pipeline
Now that the pipeline is created, you can trigger it to execute the tasks specified in the pipeline.
First, you should create a number of PipelineResources
that contain the specifics of the git repository and image registry to be used in the pipeline during execution. Expectedly, these are also reusable across multiple pipelines.
The following PipelineResource
defines the git repository for the frontend application:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: ui-repo
spec:
type: git
params:
- name: url
value: http://github.com/openshift-pipelines/vote-ui.git
And the following defines the OpenShift internal image registry for the frontend image to be pushed to:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: ui-image
spec:
type: image
params:
- name: url
value: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/vote-ui:latest
And the following PipelineResource
defines the git repository for the backend application:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: api-repo
spec:
type: git
params:
- name: url
value: http://github.com/openshift-pipelines/vote-api.git
And the following defines the OpenShift internal image registry for the backend image to be pushed to:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: api-image
spec:
type: image
params:
- name: url
value: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/vote-api:latest
Create the above pipeline resources via the OpenShift Web Console or by running the following:
oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/master/01_pipeline/03_resources.yaml
Note :-
If you are not into the
pipelines-tutorial
namespace, and using another namespace for the tutorial steps, please make sure you update the frontend and backend image resource to the correct url with your namespace name like so :
image-registry.openshift-image-registry.svc:5000/<namespace-name>/vote-api:latest
You can see the list of resources created using tkn
:
tkn resource ls
NAME TYPE DETAILS
api-repo git url: http://github.com/openshift-pipelines/vote-api.git
ui-repo git url: http://github.com/openshift-pipelines/vote-ui.git
api-image image url: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/vote-api:latest
ui-image image url: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/vote-ui:latest
A PipelineRun
is how you can start a pipeline and tie it to the git and image resources that should be used for this specific invocation. You can start the pipeline using tkn
:
tkn pipeline start build-and-deploy \
-r git-repo=api-repo \
-r image=api-image \
-p deployment-name=vote-api
Pipelinerun started: build-and-deploy-run-z2rz8
In order to track the pipelinerun progress run:
tkn pipelinerun logs build-and-deploy-run-z2rz8 -f -n pipelines-tutorial
tkn pipeline start build-and-deploy \
-r git-repo=ui-repo \
-r image=ui-image \
-p deployment-name=vote-ui
Pipelinerun started: build-and-deploy-run-xy7rw
In order to track the pipelinerun progress run:
tkn pipelinerun logs build-and-deploy-run-xy7rw -f -n pipelines-tutorial
As soon as you start the build-and-deploy
pipeline, a pipelinerun will be instantiated and pods will be created to execute the tasks that are defined in the pipeline.
tkn pipeline list
NAME AGE LAST RUN STARTED DURATION STATUS
build-and-deploy 6 minutes ago build-and-deploy-run-xy7rw 36 seconds ago --- Running
Above we have started build-and-deploy
pipeline, with relevant pipeline resources to deploy backend/frontend application using single pipeline
tkn pipelinerun ls
NAME STARTED DURATION STATUS
build-and-deploy-run-xy7rw 36 seconds ago --- Running
build-and-deploy-run-z2rz8 40 seconds ago --- Running
Check out the logs of the pipelinerun as it runs using the tkn pipeline logs
command which interactively allows you to pick the pipelinerun of your interest and inspect the logs:
tkn pipeline logs -f
? Select pipelinerun: [Use arrows to move, type to filter]
> build-and-deploy-run-xy7rw started 36 seconds ago
build-and-deploy-run-z2rz8 started 40 seconds ago
After a few minutes, the pipeline should finish successfully.
tkn pipelinerun list
NAME STARTED DURATION STATUS
build-and-deploy-run-xy7rw 1 hour ago 2 minutes Succeeded
build-and-deploy-run-z2rz8 1 hour ago 19 minutes Succeeded
Looking back at the project, you should see that the images are successfully built and deployed.

You can get the route of the application by executing the following command and access the application
oc get route vote-ui --template='http://{{.spec.host}}'
If you want to re-run the pipeline again, you can use the following short-hand command to rerun the last pipelinerun again that uses the same pipeline resources and service account used in the previous pipeline run:
tkn pipeline start build-and-deploy --last
Whenever there is any change to your repository we need to start pipeline explicitly to see new changes to take effect
Last updated
Was this helpful?