JENKINS INSTALLATION
We need to launch an instance of t2.micro with a security group of all traffic and source anywhere.
allow port 8080
So, here I am using the Ubuntu system for installing Jenkins:
Login into AWS and search for EC2 in services
Click on EC2 and explore the dashboard.:
Use the following commands for installing Jenkins.
Step 1: Create a script file and paste the following commands into the file.
sudo nanojenkins.sh
.......................
#remove $ sign before execution of script
$sudo apt-get update
$sudo apt-get install ca-certificates
$sudo apt-get install openjdk-11-jdk -y
$wget -q -O -pkg.jenkins.io/debian-stable/jenkins.io.key| sudo apt-key add -
$sudo sh -c 'echo debpkg.jenkins.io/debian-stablebinary/ > /etc/apt/sources.list.d/jenkins.list'
$sudo apt-get update
$sudo apt-get install jenkins -y
bash jenkins.sh
if not working give permission chmod 777 Jenkins.sh then do the step
Installation of jenkins using a war file
https://get.jenkins.io/war-stable/2.361.2/jenkins.war
OR
Another way on ec2
1. Configure EC2
Enter the name of your server like "Jenkins server" and choose Amazon Machine Image(AMI). An AMI is a template that contains a software configuration (for example, an operating system, an application server, and applications). In my case, I am selecting Ubuntu Server 22.04.
2. Create new key pair
Choose the instance type eligible for the free tier ( t2.micro) or higher instance type based on your server requirements. Click Create new key pair.
The key pair will allow you to SSH into the machine you just created. Create the key pair and download it, make sure to keep it safe as you will not be able to download it again. Choose key pair type as RSA and .pem as private key format and click Create key pair.
3. Configure network settings and Storage
Keep VPC and Subnet defaults in the network setting. Edit the security group and allow HTTP traffic from the internet at port 8080, by default, Jenkins runs on port 8080. Allow SSH at port 22 from anywhere. Select the amount of storage you want for your system, 8 GB is eligible for the free tier.
4. Advance details
Expand the advanced details section and scroll to the end. Copy and paste the user data script to install Jenkins at the time of launch. Lastly, click Launch instance in the bottom right corner.
#!/bin/bash
sudo apt update -y
sudo apt-get upgrade -y
sudo apt install openjdk-11-jdk -y
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins -y
Your instance is running now, In order to access Jenkins in your local click the instance id of a running instance.
Click on your instance id and copy the Public IPv4 address.
5. Access Jenkins
Go to your browser and search with Public IPv4 address:8080.
sudo cat /var/lib
6. Connect to your instance
Click the connect option in your instance menu. Go to the EC2 Instance Connect option and click connect.
Copy the path from the browser and cat into the EC2 terminal as shown below. Be the root user first:
sudo -i
cat /var/lib/jenkins/secrets/initialAdminPassword
to get the password then
Copy the password and paste it into the Jenkins console. Install suggested plugins. Set your username and password for future login.
Finally, start using the jenkins.
ALSO
For troubleshooting please use the restart jenkins command
\>\> systemctl restart jenkins ( this might resolve issues some times)
Now give public ip address:8080 in the browser
(public ip of the ec2 instance)
You need to open 8080 from security group
systemctl restart jenkins
If everything is good
If asked for password
Open a terminal and give the following command to get the password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Give the password and install suggested plugins
Create username and password , please give email address
CONGO ,,,,, FINALLY DONE!!
๐ Iโm interested in learning and working with community , open source contribution and give back to the community.
โท๏ธ I'm currently working with Kubernetes, Docker, Ansible, AWS, Jenkins, Terraform, CI/CD, Git & GitHub
๐๏ธ Iโm looking to collaborate on GitHub and open source projects related to cloud computing and Devops.
๐ฌ Ask me about DevOps, Linux-Ubuntu, Kubernetes, Docker, Ansible, Jenkins, CI/CD, Bash, Shell
๐ซ Reach out to me at whatkanish@gmail.com