mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-06 06:46:26 +01:00
Workspace YAML changes 1 Workspace YAML changes 2 minor edit QE review 1 note on migration from Resources to workspaces added new section for PVC volumes and front end correction update PVC link fix review comments review comments
130 lines
3.5 KiB
Plaintext
130 lines
3.5 KiB
Plaintext
// This module is included in the following assembly:
|
|
//
|
|
// *openshift_pipelines/creating-applications-with-cicd-pipelines.adoc
|
|
|
|
[id="adding-triggers_{context}"]
|
|
= Adding Triggers to a Pipeline
|
|
|
|
Triggers enable Pipelines to respond to external GitHub events, such as push events and pull requests. After you have assembled and started the Pipeline for the application, add TriggerBindings, TriggerTemplates, and an EventListener to capture the GitHub events.
|
|
|
|
[discrete]
|
|
.Procedure
|
|
. Copy the content of the following sample `TriggerBinding` YAML file and save it:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: triggers.tekton.dev/v1alpha1
|
|
kind: TriggerBinding
|
|
metadata:
|
|
name: vote-app
|
|
spec:
|
|
params:
|
|
- name: git-repo-url
|
|
value: $(body.repository.url)
|
|
- name: git-repo-name
|
|
value: $(body.repository.name)
|
|
- name: git-revision
|
|
value: $(body.head_commit.id)
|
|
----
|
|
|
|
. Create the `TriggerBinding`:
|
|
+
|
|
----
|
|
$ oc create -f <triggerbinding-yaml-file-name.yaml>
|
|
----
|
|
+
|
|
Alternatively, you can create the `TriggerBinding` directly from the `pipelines-tutorial` Git repository:
|
|
+
|
|
----
|
|
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/release-tech-preview-2/03_triggers/01_binding.yaml
|
|
----
|
|
|
|
. Copy the content of the following sample `TriggerTemplate` YAML file and save it:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: triggers.tekton.dev/v1alpha1
|
|
kind: TriggerTemplate
|
|
metadata:
|
|
name: vote-app
|
|
spec:
|
|
params:
|
|
- name: git-repo-url
|
|
description: The git repository url
|
|
- name: git-revision
|
|
description: The git revision
|
|
default: release-tech-preview-2
|
|
- name: git-repo-name
|
|
description: The name of the deployment to be created / patched
|
|
|
|
resourcetemplates:
|
|
- apiVersion: tekton.dev/v1beta1
|
|
kind: PipelineRun
|
|
metadata:
|
|
name: build-deploy-$(tt.params.git-repo-name)-$(uid)
|
|
spec:
|
|
serviceAccountName: pipeline
|
|
pipelineRef:
|
|
name: build-and-deploy
|
|
params:
|
|
- name: deployment-name
|
|
value: $(tt.params.git-repo-name)
|
|
- name: git-url
|
|
value: $(tt.params.git-repo-url)
|
|
- name: git-revision
|
|
value: $(tt.params.git-revision)
|
|
- name: IMAGE
|
|
value: image-registry.openshift-image-registry.svc:5000/pipelines-tutorial/$(tt.params.git-repo-name)
|
|
workspaces:
|
|
- name: shared-workspace
|
|
persistentvolumeclaim:
|
|
claimName: source-pvc
|
|
----
|
|
|
|
. Create the `TriggerTemplate`:
|
|
+
|
|
----
|
|
$ oc create -f <triggertemplate-yaml-file-name.yaml>
|
|
----
|
|
+
|
|
Alternatively, you can create the `TriggerTemplate` directly from the `pipelines-tutorial` Git repository:
|
|
+
|
|
----
|
|
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/release-tech-preview-2/03_triggers/02_template.yaml
|
|
----
|
|
|
|
. Copy the contents of the following sample `EventListener` YAML file and save it:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: triggers.tekton.dev/v1alpha1
|
|
kind: EventListener
|
|
metadata:
|
|
name: vote-app
|
|
spec:
|
|
serviceAccountName: pipeline
|
|
triggers:
|
|
- bindings:
|
|
- name: vote-app
|
|
template:
|
|
name: vote-app
|
|
----
|
|
|
|
. Create the `EventListener`:
|
|
+
|
|
----
|
|
$ oc create -f <eventlistener-yaml-file-name.yaml>
|
|
----
|
|
+
|
|
Alternatively, you can create the `EvenListener` directly from the `pipelines-tutorial` Git repository:
|
|
+
|
|
----
|
|
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/release-tech-preview-2/03_triggers/03_event_listener.yaml
|
|
----
|
|
|
|
. Expose the EventListener service as an {product-title} route to make it publicly accessible:
|
|
+
|
|
----
|
|
$ oc expose svc el-vote-app
|
|
----
|