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# ”.

Create the project cicd-YOUR#

$ oc new-project cicd-YOUR#

Switch modes to


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

$ oc new-app jenkins-ephemeral
$ oc logs -f dc/jenkins
--> Scaling jenkins-1 to 1
--> Success

Wait for logs to return "Success". Note: This may take awhile.

In "Developer" mode, click "+Add"



Select the "From Catalog" button, Select "Template"

Filter on "Jenkins (Ephemeral)". Then select "Jenkins (Ephemeral)".



Click


Select the Project cicd-YOUR# from "Namespace"


Scroll down to the bottom, and click



Go to "Topology", select the deployment configuration for jenkins, under details ... wait to pod scales to 1.

Create a sample application configuration

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

Confirm you can access Jenkins

Get the route to the Jenkins server. Your HOST/PORT values will differ from the example below.
$ oc get route
NAME       HOST/PORT                            PATH      SERVICES   PORT      TERMINATION     WILDCARD
frontend   frontend-cicd.192.168.42.27.xip.io             frontend   <all>     edge            None
jenkins    jenkins-cicd.192.168.42.27.xip.io              jenkins    <all>     edge/Redirect   None

Use Jenkins HOST/PORT to access through web browser

In "Developer" mode, 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

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

From the "Actions" menu, choose "Start Build"

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 application is available

In "Developer" mode, 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