Install Jenkins and Connect GitHub
Step-1: Install Java
- Update your system
sudo apt-get update
- Install Java
sudo apt install openjdk-11-jre
- Validate Installation
java -version
Step 2: Install Jenkins
- 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
- 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'
- Update the system:
sudo apt update
- Install Jenkins and its dependencies:
sudo apt install jenkins
Step 3: Start Jenkins:
- Start it by using
systemctl
:
sudo systemctl start jenkins
- 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>