DEV Community

Cover image for Let's create a ci/cd pipeline with Jenkins:
Rahul Kumar
Rahul Kumar

Posted on • Updated on

Let's create a ci/cd pipeline with Jenkins:

What is Jenkins :

Jenkins is a opensource tool used for automating the application deployment and delivery . Jenkins can be used for building , packaging , testing and deploying the application . Which is more often called as a ci/cd pipeline .

What is ci/cd pipeline :

ci/cd pipeline is a part of Devops lifecycle it comes under deployment phase . Where we have to pass our application through version control , building , testing and then deploy our application to the testing environment first secondly to the production environment this phase is completely automated by using a continuous integration and continuous deployment pipeline so that we make sure our application delivery time is reduced .

ci/cd pipeline

Install and configure Jenkins :

Here we are doing it on ubuntu machine you can do it on any operating system your choice .

Installing Jenkins :

  • before installing make sure you have java install .

$sudo apt-get install openjdk-11-jdk

$wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

$sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'

$sudo apt-get update

$sudo apt-get install jenkins

Enabling Jenkins to run :

by default Jenkins is running on port 8080 so we have to enable Jenkins on the system startup .

$sudo systemctl status jenkins

$sudo systemctl enable jenkins

opening the firewall :

If you have firewall enabled make sure it accepts all the incoming request through port 8080 .

$sudo ufw status

$sudo ufw allow 8080

setting up jenkins :

Then open go to port 8080 on your local machine

http://localhost:8080

if you are running it on a remote machine then simply replace the host ip or domain instead of localhost .

http://host_ip:8080

  • set up the default password by navigating to the directory .

set up jenkins

  • install suggested plugins .

suggested plugins

Lets create a pipeline :

  1. Create a webhook with GitHub so when we push the code to GitHub it can automatically do the desired step(Building, packaging, testing .)
  2. Go to your GitHub repository .
  3. Then settings .
  4. Then Webhook .
  5. Then Type the URL of your server with

$http://(ip address):8080/github-webhook/

2.Then in Jenkins you have to create a new job .

  • Add git as a version code and repository URL .
  • Then under the build triggers select

build triggers

  • Then under build select execute shell
    Alt Text

  • Then when you push your code to the github you can see a build status
    Alt Text

Multi tire architecture :

In real world scenario deploying an application passes through multiple stages .

  1. First the developer has to write the code and push the code to version control system .
  2. Through WebHook which is triggering point when ever someone pushes code to github it will trigger some work and in our case it is pushing the code to Jenkins .
  3. Then we have to run the test cases if everything is fine, the code might goes under a penetration testing environment then if it will meet all the business requirements then finally to the production server .

CI/CD pipeline

Above image shows a minimalistic process. Where as different organization follow different steps before pushing there code to the production server.

Top comments (0)