Assembling a pipeline
A Pipeline
represents a CI/CD flow and is defined by the Tasks
to be executed. It specifies how the Tasks
interact with each other and their order of execution using the inputs
, outputs
, and the run-After
parameters. It is designed to be generic and reusable in multiple applications and environments.
For this tutorial, we create a Pipeline
that takes the source code of the Spring PetClinic application from GitHub, builds the application, and deploys it on OpenShift as outlined below:
Procedure
-
Copy the contents of the following sample
Pipeline
YAML file and save it:apiVersion: tekton.dev/v1alpha1 kind: Pipeline metadata: name: petclinic-deploy-pipeline spec: resources: - name: app-git type: git - name: app-image type: image tasks: - name: build taskRef: name: s2i-java-8 params: - name: TLSVERIFY value: "false" resources: inputs: - name: source resource: app-git outputs: - name: image resource: app-image - name: deploy taskRef: name: openshift-client runAfter: - build params: - name: ARGS value: "rollout latest spring-petclinic"
This
Pipeline
performs the following tasks:-
Clones the source code of the application from a Git repository (app-git resource).
-
Builds the container image using the S2I task which generates a Dockerfile for the application and uses Buildah to build an image.
-
The application image is then pushed to an image registry (app-image resource).
-
The new application image is deployed on OpenShift using the OpenShift-CLI.
Note that, the
Pipeline
YAML file contains no references to the PetClinic Git repository and its image in the registry. These are defined in thePipelineResources
.Pipeline
s in Tekton are designed to be generic and re-usable across environments and stages through the applications lifecycle. They abstract away the specifics of the Git source repository and image registries to be used duringPipeline
execution.The execution order of the tasks is determined by the dependencies defined between the tasks using the
inputs
andoutputs
parameters, and the explicit orders that are defined usingrunAfter
.
-
-
Create the
Pipeline
:$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/master/pipeline/01-build-deploy.yaml
-
Verify that the
Pipeline
has been added to the application as follows:$ tkn pipeline ls NAME AGE LAST RUN STARTED DURATION STATUS deploy-pipeline 8 seconds ago --- --- --- ---