Install Jenkins and Connect GitHub

Step-1: Install Java

  1. Update your system
sudo apt-get update
  1. Install Java
sudo apt install openjdk-11-jre
  1. Validate Installation
java -version

Step 2: Install Jenkins

  1. First, add this repo key to your system
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg
  1. Append the Debian package repository address to the server’s sources.list:
sudo sh -c 'echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  1. Update the system:
sudo apt update
  1. Install Jenkins and its dependencies:
sudo apt install jenkins

Step 3: Start Jenkins:

  1. Start it by using systemctl:
sudo systemctl start jenkins
  1. Check the status:
sudo systemctl status jenkins

And You are done with Jenkins Installation!

Step 4: Connect Github with Jenkins:

Step 1: Generate ssh-key on your system:

ssh key-gen

Step 2: Go to your git-hub account and paste the id_rsa.pub

Step 3: Go to jenkins--> Manage Jenkins--> Manage Credentials

And, Inside create credentials ("kind: SSH username with private key").

Paste the id_rsa/private key:

Step 3: Change, Git Host key Verification Configuration--> Accept first connection

And you are done!

We have created our first Pipeline...!

ISSUE:
If you are facing any issue as:

try this: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <the key>