Lab 8 - CI / CD Pipeline

Return to Workshop

CI/CD Defined

In modern software projects many teams utilize the concept of Continuous Integration (CI) and Continuous Delivery (CD). By setting up a tool chain that continuously builds, tests, and stages software releases, a team can ensure that their product can be reliably released at any time. OpenShift can be an enabler in the creation and management of this tool chain.

In this lab we walk through creating a simple example of a CI/CD [pipeline] utilizing Jenkins, all running on top of OpenShift! The Jenkins job will trigger OpenShift to build and deploy a test version of the application, validate that the deployment works, and then tag the test version into production.

Create a new project

Create a new project named “cicd-YOUR# ”.

Terminal access

http://workshop-terminal-terminal-YOUR#.apps.example.redhatgov.io

Create the project cicd-YOUR#

$ oc new-project cicd-YOUR#

Web Console access

https://console-openshift-console.apps.example.redhatgov.io
From the "Developer" view, click "Topology", Select "Project:" drop down, and click "Create Project"


Fill in the Name and Display Name of the project as "cicd-YOUR# " and click "Create"

Instantiate a Jenkins server in your project

Terminal access

http://workshop-terminal-terminal-YOUR#.apps.example.redhatgov.io
$ oc new-app jenkins-ephemeral
$ oc logs -f dc/jenkins

Wait for logs to return “Success”.

NOTE: this may take some time

Web Console access

https://console-openshift-console.apps.example.redhatgov.io
In "Developer" view, click "+Add"



From the "Developer Catalog", Select "All services"
Search for "Jenkins"
Select "Jenkins (Ephemeral)".



Click


Select the cicd-YOUR# from available "Namespace"


Scroll down to the bottom, and click





Create a sample application configuration

If you are following the Web Console steps, first make sure you are in the “cicd-YOUR# ” project

oc project cicd-YOUR#

$ oc project cicd-YOUR#

$ oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/jenkins/pipeline/nodejs-sample-pipeline.yaml

Confirm you can access Jenkins

Terminal access

http://workshop-terminal-terminal-YOUR#.apps.example.redhatgov.io
Get the route to the Jenkins server:
$ oc get route | grep jenkins | awk '{ print $2 }'

Copy the above URL, and paste it in your web browser, to access Jenkins.

Web Console access

https://console-openshift-console.apps.example.redhatgov.io
In "Developer" view, under "Topology", click the arrow, in the upper right corner of the "jenkins" icon


Select “Login with OpenShift” from Jenkins login page


The OpenShift login page is displayed in a new browser tab.

Login with your OpenShift user name and password


Once logged in, click the [Allow selected permissions] button and you should see the Jenkins dashboard.

Start the pipeline

Terminal access

http://workshop-terminal-terminal-YOUR#.apps.example.redhatgov.io

Launch the pipeline:

$ oc start-build nodejs-sample-pipeline

Web Console access

https://console-openshift-console.apps.example.redhatgov.io

Using the OpenShift Web Console, in “Administrator” view, choose Builds -> Build Configs, and then click on “nodejs-sample-pipeline”

From the “Actions” menu, choose “Start Build”

Monitor the pipeline’s progress

When the pipeline starts, OpenShift uploads the pipeline to the Jenkins server for execution.

The Jenkins dashboard should indicate that a new build is executing.

Back in the OpenShift Web Console, watch the pipeline execute.

Confirm that the application is available

In "Developer" view, select the "cicd-YOUR#" project, and click on "Topology"


Click on the arrow, at the upper right corner of the "nodejs-mongodb6-example" icon, to launch the web page

Service web page displayed:


Summary

In this lab you have very quickly and easily constructed a basic pipeline.


Workshop Details

Domain Red Hat Logo
Workshop
Student ID

Return to Workshop