Build and Deploy Continuous Delivery Pipeline with Jenkins
Reading Time: 2 Minutes
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.
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.
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.
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.
Now need to configure GitLab to trigger the builds. We&rsquo'll do this with webhooks, and shall need one per Jenkins job.