Hidden Tricks of Jenkins to Bolster Continuous Integration on Pivotal Cloud Foundry

This blog post explores 'underestimated' features in Jenkins, such as plugins for generating, editing, and debugging code.

Why use Jenkins on Pivotal CF?

Jenkins is one of the many solutions developers use for continuous integration and continuous delivery (CI/CD). At the SpringOne Platform convention 2017, Andrei Krasnitski of Altoros gave attendees insights into which of the plugins for Jenkins are underrated by developers.

Firstly, Andrei listed a few reasons why using Jenkins at all. In addition to the ease of use / installation / setup, Jenkins provides support for all environments, has extensive documentation and tutorials, requires low input threshold, and is highly customizable.

With Jenkins, users can implement their own features within their own Jenkins files, which are then made available to other Jenkins users. This simplifies troubleshooting as developers can just share solutions to problems.

“If you need help with a difficult step and know that someone from your team has already solved the problem, you just need to import the function, and you can use it in your own pipeline file,” explained Andrei.

“When you start your CI/CD journey, you need to understand that the process is more complicated than just build, test, and deploy.” —Andrei Krasnitski

By storing pipeline code in a shared repository like GitHub, disaster recovery is as simple as going back to a previous build. This also enables developers to easily track changes made to the code, as well as who made them.

Though Concourse is a great CI/CD tool built specifically for Cloud Foundry, Jenkins is still a solution of choice for many developers who are used to working with it. The good news is that it can be enabled by simply using this PCF tile. All you need is “download the tile from the Pivotal Network, import it to the PCF Ops Manager, and then click to apply changes,” noted Andrei.

 

An ecosystem of Jenkins plugins

At large, the ease of customization provided by Jenkins comes through its eloquent ecosystem of 1,000+ plugins. A substantial part of the tool’s core functionality “is written in terms of extensions” and can be enhanced by plugins.

The Jenkins documentation exemplifies the following extension points:

  • Implementation of software configuration management systems like Git or Subversion
  • Build steps, furnishing a users with anything necessary from a UI for configuring tools to a preferable means of sending e-mails
  • Authentication modules—ensuring integration with single sign-on systems or external user directories (e.g., LDAP or Active Directory)

“Jenkins is easy to customize. You can create your own plugin if you have basic experience in Java and install this plugin with a couple of clicks using the Jenkins web UI.”
—Andrei Krasnitski

Surely, the list is by no means exhaustive. This tutorial and this wiki shed more light on how to create a Jenkins plugin of your own.

 

Kubernetes Deep Dive DC

Underrated plugins for Jenkins

After that, Andrei brought up some non-standard Jenkins features that come as plugins and are useful for development.

E.g., Snippet Generator is a tool within Jenkins that enables users to generate code for individual steps and discover steps provided by plugins. Snippet Generator also helps users to experiment with particular steps by using different parameters.

Snippet Generator view on the Jenkins web UI

Another example of Jenkins’s neglected feature is Blue Ocean. It is a visual editor that allows for modifying pipelines as code. Blue Ocean has native integration for branch and pull requests. It also shows which portion of the pipeline needs fixing in case of errors.

Blue Ocean view on the Jenkins web UI

Other than Blue Ocean, Jenkins also has additional solutions for debugging pipeline code. One of these tools is Command-line Pipeline Linter, which allows developers to check and validate pipeline files. Jenkins also has the Replay function for editing the pipeline after a build failure.

Jenkins has also been updated to include Multibranch Pipeline capability. “The multibranch workflow automatically takes the pipeline files from the old branch available in the repo and creates a separate test for each of the branches,” explained Andrei. “You don’t need to configure each of the new branches separately in the new Jenkins.”

Andrei Krasnitski at the SpringOne Platform convention

This is complemented by the Organization Folders feature, which makes Jenkins monitor a GitHub organization and automate pull requests.

 

Containers of choice

According to Andrei, the three most common containers used in conjunction with Jenkins are Docker, Kubernetes, and Apache Mesos. Using containers, resources such as CPU and memory can be isolated and configured based on priority. More importantly, each build automatically creates its own container.

Docker files used as Jenkins slaves

Of the three containers, Docker is probably the preferred option—due to its ease of use. “If you need a tool to be available during your build process, you just need to modify your Docker file,” explained Andrei. “You need to add a couple of lines to install your favorite Ruby, Python, or Go version.”

For users working with Docker, this tile for PCF automates Jenkins follower provisioning, as well as resolves high availability issues through BOSH deployments. In addition to integrated monitoring and logging, the Jenkins tile also allows users to choose when to upgrade and what versions of software should be used when the new instances are created.

The workflow of the Jenkins tile for PCF (Source)

In a nutshell, the Jenkins tile for PCF allows for:

  • Bootstrapping new Jenkins followers, already preconfigured to work with a Jenkins master
  • Enhancing release engineering through automated CI/CD
  • Resolving HA issues in default Jenkins installations via BOSH deployments

To learn more about the tile, check out its documentation. For other container options than Docker, explore a Kubernetes plugin or a Mesos plugin for Jenkins.

During his presentation, Andrei demonstrated many of the Jenkins tools mentioned above.

 

Want details? Watch the video!

Table of contents
  1. Why use Jenkins? (2:01)
  2. Useful out-of-the-box features (4:11)
  3. How can Jenkins improve CI/CD? (5:26)
  4. Demo: Snippet Generator (7:30)
  5. Demo: Blue Ocean (10:57)
  6. Demo: Command-line Pipeline Linter (13:52)
  7. Demo: The replay function (14:58)
  8. Working with multiple development branches (16:04)
  9. Containers that work with Jenkins (18:19)

 

Related slides

 

Further reading

 

About the expert

Andrei Krasnitski, altoros bio
Andrei Krasnitski is Cloud Foundry Engineer at Altoros. He has 3+ years of experience in building CI/CD pipelines and automating clouds. Andrei has participated in building a private cloud for one of the largest US-based IT service providers. Today, he is creating and supporting Cloud Foundry environments for the enterprise customers of Altoros.

 


This post was written by Carlo Gutierrez and Sophie Turol
with assistance from Andrei Krasnitski and Alex Khizhniak.

To stay tuned with the latest updates, subscribe to our blog or follow @altoros.

  •  
  •  
  •