Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

OpenShift Pipelines with Jenkins Blue Ocean

DZone's Guide to

OpenShift Pipelines with Jenkins Blue Ocean

The Blue Ocean project was conceived to revisit the Jenkins user experience and redesign it to follow new trends of interacting with pipelines.

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

This article was originally posted on the OpenShift Blog at https://blog.openshift.com/openshift-pipelines-jenkins-blue-ocean.

Jenkins is one of the most popular open-source automation engines and it has been the leading CI engine used in most development projects. As more and more organizations adopt DevOps and Continuous Delivery, Jenkins has been getting more focus as a tool for building CI/CD pipelines which resulted in Jenkins 2.x bringing in Pipelines as a built-in feature and enable building complex CI/CD pipelines using the Groovy-based pipeline DSL.

Despite the native pipeline support in Jenkins, the UI and user experience have been mostly intact and inherited from an earlier version, which made visualization of pipelines somewhat technical and limiting. The Blue Ocean project was conceived to revisit the Jenkins user experience and redesign it from the ground up to accommodate the new ways people build and interact with pipelines. The new UX features provide visualizations of CI/CD pipelines, an editor for creating pipelines, dashboard personalization, the ability to pinpoint issues, and native integration for Git repository branch and pull requests.

Jenkins Blue Ocean

The waiting is over and Jenkins Blue Ocean 1.0 has finally been released. Like you, we couldn’t wait to get our hands on it and in this blog, we show you how to use Blue Ocean with OpenShift Pipelines. OpenShift Pipeline allows developers to define a Jenkins pipeline for execution by Jenkins server and can be started, monitored, and managed by OpenShift in a single place with other build types (source code build, Docker build, etc).

Deploying Blue Ocean on OpenShift

OpenShift provides a certified Jenkins Docker image with a set of common plugins pre-configured on it. The provided Jenkins Docker image supports Source-To-Image (S2I) builds in order to easily and without hassle be able to customize the Jenkins Docker image with plugins, job definitions, global configurations, etc and produce a customized Jenkins Docker image to be used within your projects.

The first step is to create a project and an S2I build to customize the Jenkins Docker image and install the Blue Ocean plugin on it. All we need to do is to create a file called  plugins.txt  which lists the Jenkins plugins we want to install in the root of a Git repository and point the S2I buildconfig to that Git repo. We have created an example of  plugins.txt  and the buildconfig in this GitHub repository:

$ oc new-project ci
$ oc new-build jenkins:2~https://github.com/siamaksade/jenkins-blueocean.git --name=jenkins-blueocean


A build called jenkins-blueocean is created and is running to produce our customized Jenkins docker image with the Blue Ocean plugin installed. You can see the logs as the build runs using OpenShift CLI or OpenShift Web Console:

$ oc logs -f bc/jenkins-blueocean

Build Configs

When the build completes, we can deploy our customized Jenkins Docker image using the Jenkins templates available in OpenShift.

$ oc new-app jenkins-ephemeral \
    -p NAMESPACE=ci \
    -p JENKINS_IMAGE_STREAM_TAG=jenkins-blueocean:latest \
    -p MEMORY_LIMIT=2Gi


After a few seconds, the customized Jenkins Docker image gets deployed in the ci  project.

Image title

Click on Jenkins route URL and open it in a new tab. The Jenkin Docker image in OpenShift is integrated into OpenShift OAuth authentication, and therefore, you can simply use your OpenShift credentials to log in to Jenkins. Clicking on the Open Blue Ocean button on the top takes you the new Jenkins user experience, Blue Ocean.

Image title

Create an OpenShift Pipeline

We will use a Spring Boot application in this blog post which is called Cart Service. Cart Service is a microservice that provides shopping cart services via REST API.

Let’s deploy the Cart Service on OpenShift using Red Hat’s officially supported OpenJDK S2I image:

$ oc create -f https://raw.githubusercontent.com/jboss-openshift/application-templates/master/jboss-image-streams.json
$ oc process -f https://raw.githubusercontent.com/siamaksade/cart-service/master/openshift/cart-template.yaml -v IMAGE_STREAM_NAMESPACE=ci | oc create -f -


The above commands create the build and deployment objects required to build and package the Cart Service as a JAR artifact using OpenShift S2I and build a Docker image by layering the JAR file on an OpenJDK Docker image. The result is a Cart Service docker image which is then deployed as a container on OpenShift.

After the build and deployment are complete, you can verify the service is running using curl or pointing your browser to one of the REST API endpoints:

$ curl http://cart-ci.your-openshift-domain/api/cart/FOO

{"cartItemTotal":0.0,"cartItemPromoSavings":0.0,"shippingTotal":0.0,"shippingPromoSavings":0.0,"cartTotal":0.0,"shoppingCartItemList":[]}


The Cart Service GitHub repository also includes a Jenkinsfile which defines a CI/CD pipeline using the Jenkins Pipeline DSL. We create an OpenShift Pipeline that references this Jenkinsfile and uses it as the pipeline definition.

$ oc create -f https://raw.githubusercontent.com/siamaksade/cart-service/master/openshift/cart-pipeline.yaml


We can start the pipeline by clicking on the Start Pipeline button under Builds → Pipelines. OpenShift creates an instance of the pipeline using the Jenkinsfile in the aforementioned GitHub repository and starts running it on Jenkins.

OpenShift Pipelines


Switch to the Jenkins Blue Ocean tab and notice that the pipeline is automatically created on Jenkins by OpenShift and is running.
Blue OceanBlue Ocean
Any change in the pipeline definition in OpenShift automatically updates Jenkins and vice versa. You can also use the Blue Ocean Pipeline Editor, Pull-Request and Branch builds, and other goodies that come with Blue Ocean together with OpenShift Pipelines.

Jenkins Blue Ocean is the new user experience for Jenkins to provide more flexibility for building and interacting with CI/CD pipelines. Using an OpenShift certified Jenkins Docker image and S2I process for customizing Jenkins, Blue Ocean can easily be enabled in Jenkins on OpenShift. OpenShift Pipeline, which allows developers to define a Jenkins pipeline for execution by Jenkins server while it is started, monitored, and managed by OpenShift, works out-of-the-box with Jenkins Blue Ocean and enables developers to combine the new user experience of Blue Ocean with ease-of-use and manageability of OpenShift Pipelines.


The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:
ci/cd ,jenkins ,openshift ,containers ,devops ,blue ocean ,continuous delivery

Published at DZone with permission of Siamak Sadeghianfar. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}