Build and Deploy Continuous Delivery Pipeline with Jenkins

Reading Time: 2 Minutes

by Navdeep Singh Gill | June 15, 2018  Build and Deploy Continuous Delivery Pipeline with Jenkins

Getting Started with Jenkins

Jenkins is an Open Source Automation server, Jenkins helps to automate the software development process, with Continuous Integration and by facilitating technical aspects of continuous delivery.It works on a distributed network which helps build tests and deploy faster.

Introduction to Continuous Delivery

Continuous delivery is a branch of continuous integration. It concentrates on automating the software delivery process so that teams can quickly and confidently deploy their code to production at any point. 

Introduction to Continuous Integration

Here Jenkins shall be used in order to create a continuous integration pipeline for NodeJs applications. Jenkins contains a number of plugins, so in order to make Jenkins compatible with other tools such as gitlab, docker or kubernetes we shall need to install the required plugins.

Jenkins being a java application can be installed both as a standalone application and on tomcat servlet. Here we shall install and run Jenkins on a docker container. By default, Jenkins runs on 8080 port. Jenkins can be installed docker using this command:-

docker run -it -p 8080:8080 jenkins:alpine

Setting up Continuous Delivery with Jenkins

In order for Jenkins to work with gitlab, install some plugins.

Go to the Jenkins dashboard > Manage Jenkins > Manage Plugins.    

Jenkins CI-CD Step 1 - Setting up Continuous Delivery with Jenkins

Search for gitlab plugins and install them.

Then in gitlab generate an API token for gitlab to talk with Jenkins.

Now go copy the token generated and go to Jenkins dashboard > credentials > system > global credentials and add the credentials there.

Jenkins CI-CD Step 2 - Adding the credentials

Now create a job >freestyle project.

Then describe your project, configure your gitlab repo in the source code management section, build the triggers and define the post-build methods if any.

Jenkins CI-CD Step 3 - Configure your Gitlab repo

For your project to build you can shell actions or configure some ansible playbooks or a bash script for deployment. Jenkins also supports Docker, Ansible, and kubernetes plugins.

We can configure Jenkins to create an image and deploy it on kubernetes.

For post-build actions configure build status to gitlab commit.

Jenkins CI-CD Step 4 - Post build Actions configure

Now need to configure GitLab to trigger the builds. We&rsquo'll do this with webhooks, and shall need one per Jenkins job.

Jenkins CI-CD Step 5 - Configure GitLab to trigger the builds

How Can XenonStack Help You?