In this article, We are going to show you, How to Install Jenkins on AWS Ec2 Ubuntu 20.04 instance. You can use the same steps to install Jenkins on other cloud platform such as Azure or Google Cloud. We are assuming that you already have your AWS account and created your AWS Ec2 Ubuntu 20.04 instance.
So, lets start it,
1.AWS account, you can create your free tier AWS account click here
2.AWS Ec2 instance key pair (Required for log into Ubuntu instance)
Log in to AWS account
Visit to AWS official website AWS and log in with your credentials.
Create Ubuntu 20.04 Ec2 Instance.
Once you logged in to your AWS account and accessed your Ubuntu Server 20.04 LTS instance you can follow the below steps to install Jenkins.
Update Ubuntu Server
Before installing Jenkins you have to update software packages on Ubuntu server for that use below commands.
sudo apt-get update -y
Add Repository Key
You have to add Jenkins repository into Ubuntu server, use below command for that.
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
Add Package Repository
Use below command to add package repository
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Now, to update the server you have to use below command;
sudo apt update
Install Jenkins Dependencies
Before install of Jenkins we have to install its dependencies. We first have to install java, for that use below command;
sudo apt install openjdk-8-jre -y
Now, you can use below command to install Jenkins
sudo apt install jenkins -y
Once jenkins installation completed you have to start Jenkins service for that use below command
sudo systemctl start jenkins sudo systemctl status jenkins
You can find below output once Jenkins service started and used above status command.
Allow Jenkins Port On Ubuntu Firewall
By default Ubuntu server has firewall installed and we have to allow Jenkins 8080 port from firewall so that we can access Jenkins. Use below command to allow port.
sudo ufw allow 8080
Note- In case Ubuntu machine firewall is inactive you can use below commands to check it
sudo ufw status
If your Ubuntu firewall is inactive use below command to active it
sudo ufw allow OpenSSH sudo ufw enable sudo ufw enable
Now, you can check firewall status and allowed ports on firewall using status command.
sudo ufw status
You could see below outputs;
Setting Up Your Jenkins
Friends, now to access Jenkins from web browser you also have to allow Jenkins port 8080 on AWS security group and after that you would be able to access Jenkins. So, go to your AWS account-Security group and add port 8080.
Now, open web browser and type your AWS Ec2 Ubuntu instance public IP address with 8080 port as mentioned in below screenshot.
As per given instructions in above screenshot you have to get default administrator password from given path so, you below command to get that on your Ubuntu machine.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
You would get below output and that is the default admin password for log in to Jenkins copy that and use in web browser for Jenkins login.
Once you logged in to Jenkins with default admin password it will give two options and that is suggested plugins and select plugins to install. We recommend you to click on suggested plugins and jenkins itself take care for plugins installations.
Plugins installation will take some time and once all plugins installed Jenkins will ask you to create your Admin user account.
Now, fill your admin user details which you want and set Jenkins admin credentials.
Now friends you get a configuration page and it will ask you to confirm your preferred URL for Jenkins instance. You can confirm either with the domain name or you can use your servers IP address.
After setting your Jenkins access url and other informations, click Save and Finish. You will finally get confirmation page and that would be “Jenkins is Ready”
You can login to Jenkins with created account and start use of Jenkins.
Hope this article helpful you. Please like, share and subscribe to https://devopsarticle.com