Skip to content

leandroberetta/openshift-cicd-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenShift CI/CD Demo

Basic demonstration of OpenShift Pipelines for deploying applications across environments.

Pipelines

pipelines

Demo

Prerequisites

  • OpenShift 4.1 or higher
  • OpenShift Pipelines installed in OpenShift

Projects

Create the projects (environments):

oc apply -R -f ./environments

Pipelines

Create the tasks:

oc apply -R -f ./tasks

Create the pipelines:

oc apply -R -f ./pipelines

Create the triggers (webhooks):

oc apply -R -f ./triggers

Get the route for the webhook:

export HELLO_EVENT_LISTENER_ROUTE=$(oc get route el-hello-event-listener -o jsonpath='{.spec.host}' -n hello-dev)

CI Pipeline (deploy to DEV building from develop branch)

A CI pipeline is started with a push event from the repository (Webhook). It can be simulated with the following command:

curl -v http://$HELLO_EVENT_LISTENER_ROUTE \
    -H 'X-GitHub-Event: push' \
    -H 'X-Hub-Signature: sha1=9f257f3c340bf1c2d116f5cd99aeacf62811b657' \
    -H 'Content-Type: application/json' \
    -d '{"ref": "refs/heads/develop","head_commit": {"id": "master"},"repository": {"url": "https://github.com/leandroberetta/openshift-cicd-demo"}}'

Note: the head_commit.id field is set to master just for demo reasons, in real scenarios the request will be generated by the repository with the correct values.

This action creates a PipelineRun:

ci-pipeline-run

CD Pipeline (deploy to TEST and PROD building from master branch)

A CD pipeline is started with a pull request event from the repository. It can be simulated with the following command:

curl -v http://$HELLO_EVENT_LISTENER_ROUTE \
    -H 'X-GitHub-Event: push' \
    -H 'X-Hub-Signature: sha1=eaf4126c4193f189bde68af2700b12d629c22674' \
    -H 'Content-Type: application/json' \
    -d '{"ref": "refs/heads/master","head_commit": {"id": "master"},"repository": {"url": "https://github.com/leandroberetta/openshift-cicd-demo"}}'

This action creates a PipelineRun:

cd-pipeline-run