1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 09:46:53 +01:00
Files
openshift-docs/modules/op-assembling-a-pipeline.adoc
Preeti 662cf8e304 Trigger doc updates
triger template description changes and release branch changes

rpm updates

clarification on trigger template and pipeline run creation

attributes and typo

replacing with version attribute

attribute label

build fix

attribute changes

attribute and build

attribute fixes

removing callouts

review fixes
2020-11-30 20:14:59 +05:30

135 lines
4.1 KiB
Plaintext

// This module is included in the following assembly:
//
// *openshift_pipelines/creating-applications-with-cicd-pipelines.adoc
[id="assembling-a-pipeline_{context}"]
= Assembling a Pipeline
A Pipeline represents a CI/CD flow and is defined by the Tasks to be executed. It is designed to be generic and reusable in multiple applications and environments.
A Pipeline specifies how the Tasks interact with each other and their order of execution using the `from` and `runAfter` parameters. It uses the `workspaces` field to specify one or more volumes that each Task in the Pipeline requires during execution.
In this section, you will create a Pipeline that takes the source code of the application from GitHub and then builds and deploys it on {product-title}.
//The image below displays the various components of `pipelines-tutorial` Pipeline, and how these components interact with each other.
//image::op-assemble-a-pipeline.png[]
The Pipeline performs the following tasks for the back-end application `vote-api` and front-end application `vote-ui`:
* Clones the source code of the application from the Git repository by referring to the `git-url` and `git-revision` parameters.
* Builds the container image using the `buildah` ClusterTask.
* Pushes the image to the internal image registry by referring to the `image` parameter.
* Deploys the new image on {product-title} by using the `apply-manifests` and `update-deployment` Tasks.
[discrete]
.Procedure
. Copy the contents of the following sample Pipeline YAML file and save it:
+
[source,yaml,subs="attributes+"]
----
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: build-and-deploy
spec:
workspaces:
- name: shared-workspace
params:
- name: deployment-name
type: string
description: name of the deployment to be patched
- name: git-url
type: string
description: url of the git repo for the code of deployment
- name: git-revision
type: string
description: revision to be used from repo of the code for deployment
default: "{pipelines-ver}"
- name: IMAGE
type: string
description: image to be build from the code
tasks:
- name: fetch-repository
taskRef:
name: git-clone
kind: ClusterTask
workspaces:
- name: output
workspace: shared-workspace
params:
- name: url
value: $(params.git-url)
- name: subdirectory
value: ""
- name: deleteExisting
value: "true"
- name: revision
value: $(params.git-revision)
- name: build-image
taskRef:
name: buildah
kind: ClusterTask
params:
- name: TLSVERIFY
value: "false"
- name: IMAGE
value: $(params.IMAGE)
workspaces:
- name: source
workspace: shared-workspace
runAfter:
- fetch-repository
- name: apply-manifests
taskRef:
name: apply-manifests
workspaces:
- name: source
workspace: shared-workspace
runAfter:
- build-image
- name: update-deployment
taskRef:
name: update-deployment
workspaces:
- name: source
workspace: shared-workspace
params:
- name: deployment
value: $(params.deployment-name)
- name: IMAGE
value: $(params.IMAGE)
runAfter:
- apply-manifests
----
+
The Pipeline definition abstracts away the specifics of the Git source repository and image registries. These details are added as `params` when a Pipeline is triggered and executed.
. Create the Pipeline:
+
----
$ oc create -f <pipeline-yaml-file-name.yaml>
----
+
Alternatively, you can also execute the YAML file directly from the Git repository:
+
[source,terminal,subs="attributes+"]
----
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/{pipelines-ver}/01_pipeline/04_pipeline.yaml
----
. Use the `tkn pipeline list` command to verify that the Pipeline is added to the application:
+
----
$ tkn pipeline list
----
+
The output verifies that the `build-and-deploy` Pipeline was created:
+
----
NAME AGE LAST RUN STARTED DURATION STATUS
build-and-deploy 1 minute ago --- --- --- ---
----