DEV Community

loading...
Cover image for Let's create a ci/cd pipeline with Jenkins:

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

rahulku48837211 profile image Rahul Kumar ・2 min read

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 :

$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

Discussion (0)

Forem Open with the Forem app