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:
And the following PipelineResource defines the git repository for the backend application:
And the following defines the OpenShift internal image registry for the backend image to be pushed to:
Create the above pipeline resources via the OpenShift Web Console or by running the following:
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 :
You can see the list of resources created using tkn:
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:
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.
Above we have started build-and-deploy pipeline, with relevant pipeline resources to deploy backend/frontend application using single pipeline
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:
After a few minutes, the pipeline should finish successfully.
Looking back at the project, you should see that the images are successfully built and deployed.
Application Deployed
You can get the route of the application by executing the following command and access the application
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:
Whenever there is any change to your repository we need to start pipeline explicitly to see new changes to take effect
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
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
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
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
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
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
oc get route vote-ui --template='http://{{.spec.host}}'