In this lab, you will learn how to create a Jenkins 2.0 Build Pipeline for our Spring application using a Maven Binary/S2I build. We enable the Pipeline to Deploy the App, Smoke Test it, and introduce a Manual Step to Tag the created Container Imagestream for Release.
In this step, we will update the initially created Deployment Configuration, to enable our Build Pipeline to control application deployment:
In this step, we will create and update our Build Pipeline, deploying a Jenkins 2.0 instance into our OpenShift project:
-
From the command line and where this project was cloned, navigate to the /lab/.openshift directory
-
Ensure you are logged into OpenShift and your Lab Project, then execute the following oc command:
oc create -f mvnBinaryBuild.yaml
-
You shoud see the message buildconfig "product-catalog-mvn-pipeline" created if the command was successful
-
From the OpenShift Web Console, under Other Resources, you should now see that a Jenkins deployment was created and in the process of starting up:
Once started, verify you can login to your Jenkins instance via the created Route using your OpenShift Credentials. Select and review the Jenkins Pipeline Job created, and DSL for our Pipeline.
-
From the OpenShift Web Console, select Builds then Pipelines, then our newly created product-catalog-mvn-pipeline
Under the Actions Drop Down on the upper right select Edit
Review the Jenkins DSL for each Stage of the Pipeline, the following updates are needed for the Pipeline to execute against your specific project:
Checkout Stage - Update the Git Repo to your personal repo that you forked from this Lab Smoke Test - Update the curl URL to the Route generated for your specific project Save your changes and then Start the Pipeline to verify successful execution
In the previous step, our Build Pipeline introducted a Manual step used to trigger release of the current build. In this step, we will "approve" the build for release and verify the image was successfully tagged:
-
From the Web Console, under the product-catalog Application, click the Tag and Relase Pipeline step and allow the Stage to proceed.
-
From the Web Console, select Builds, Images to display the existing Imagestreams. Select the product-catalog imagestream and verify that there is a latest and next-release tag.
To speed up your Jenkins Maven Build times, local Maven Mirrors can be used via the MAVEN_MIRROR_URL enivornment variable, added to your Build Pipeline Configuration. Also, persistent storage can be added to your Jenkin’s Slave Pod/Container, review the following blog for instructions - https://blog.openshift.com/decrease-maven-build-times-openshift-pipelines-using-persistent-volume-claim/