Skip to content

Latest commit

 

History

History
69 lines (56 loc) · 3.93 KB

lab2-instructions.adoc

File metadata and controls

69 lines (56 loc) · 3.93 KB

Lab 2 - Creating an OpenShift Application Build Pipeline

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.

1. Update the product-catalog Deployment Configuration

In this step, we will update the initially created Deployment Configuration, to enable our Build Pipeline to control application deployment:

  1. From the OpenShift Web Console, select the product-catalog Deployment

  2. Under the Actions Drop Down on the upper right, select Edit

  3. Scroll down to the Images section, uncheck both options that automatically start new deployments

    spring lab dcupdate1

2. Create the product-catalog Build Pipeline

In this step, we will create and update our Build Pipeline, deploying a Jenkins 2.0 instance into our OpenShift project:

  1. From the command line and where this project was cloned, navigate to the /lab/.openshift directory

  2. Ensure you are logged into OpenShift and your Lab Project, then execute the following oc command:

    oc create -f mvnBinaryBuild.yaml
  3. You shoud see the message buildconfig "product-catalog-mvn-pipeline" created if the command was successful

  4. 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:

    spring lab jenkins1

    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.

    spring lab jenkins0
  5. 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

    spring lab pipeline1

    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
    spring lab pipeline2

3. Tag the product-catalog Image for Release

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:

  1. From the Web Console, under the product-catalog Application, click the Tag and Relase Pipeline step and allow the Stage to proceed.

  2. 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.

    spring lab imagestream1

4. Optional Jenkins Build Pipeline optimizations

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/