PSD2 Developer Ecosystem - Jenkins Docker CI/CD Part 2

PSD2 Developer Ecosystem - Jenkins Docker CI/CD Part 2

In our last blog post we looked at dockerizing the PSD2 Developer Ecosystem. Following on from that, we will now look at setting up a multibranch pipeline in Jenkins driven by a Jenkinsfile for the dockerized ecosystem.

Goals

The goal for this scenario is to utilize some of the newer features of Jenkins such as pipeline as code and the ability to smoothly work with containers to achieve a compact, lightweight job that can cover all three stages of development in a demonstration development environment. While we will not go as far as deployment, this will outline some of the capabilities of newer Jenkins features and show how the PSD2 Developer Ecosystem can easily fit into a CI/CD setup.

The Setup

We have set up a single online repository for our source code and project files in Bitbucket with separate branches for Dev, QA and production along with separate docker image repositories in Docker Hub. the Jenkinsfile has been configured for each stage to use the appropriate branch and docker image repository to achieve the multibranch CI/CD cycle.

blog-02-image-01

For our Jenkins setup, we will be using a local Jenkins master with remote slave node and utilizing the Docker remote API to execute Docker commands.

blog-02-image-02

Jenkinsfiles

The Jenkinsfiles will contain the instructions for the Jobs in each of our branches. This is a key change in the way that Jenkins jobs are created. Rather than configuring the Job in the Jenkins UI, all of the instructions are now contained in a Jenkinsfile – A Groovy script which resides with the project source in the repository. When creating a new job, you simply point Jenkins to the desired repository and Jenkins will detect the instructions and build the Job from there. In a multibranch job, Jenkins will also detect each branch of the repository which contains a Jenkinsfile, and create separate Jobs contained in a single Jenkins project for each. For example, in the image below, we have a Jenkins Project called psd2-ecosystem which contains four separate branch jobs.

blog-02-image-03

SDLC and CI/CD

A general cycle in Jenkins for a dockerized application or application stack may look something like this:

blog-02-image-04

With the use of the multibranch pipeline approach, the end result would look something closer to this:

blog-02-image-05

We look at these topics in more detail in the following video where you can also see the resulting Jenkins job run for the PSD2 Ecosystem:

 

PSD2 Developer Ecosystem - Jenkins & Docker CI/CD - Part 2

 

On a larger scale, moving from a basic tool like Docker Compose to something more scalable such as Kubernetes would make more sense. But for a quick setup to sketch out a CI/CD scenario on a smaller scale in a development environment, the tools used here are perfect for proving out the concept. While this only scratches the surface of what can be achieved with some of the newer features, it is a good introduction to the process and helps to get a better overall idea of the new Jenkins features and layout before committing to a larger project.