Background
This post shows the steps we need to follow to install jenkins in an EC2 that has ubuntu OS
Steps
- ssh into your ec2
- sudo apt-get update
Java by default is not available in a EC2. However jenkins needs a java. Verify if java is available in your ec2 by invoking,
java -version
If you get the below message you need to install java before you proceed.
Command 'java' not found
*In case of missing java runtime environment (JRE) install by following the instructions at https://www.jenkins.io/doc/book/installing/linux/#installation-of-java .You can test your installation by executing the below command,
java -version
You'd get a message something like,
ubuntu@ip-172-31-40-141:~$ java -version
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-122.04)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-122.04, mixed mode, sharing)
This doc installs jenkins LTS version(Long Term Support version). Follow install script in https://www.jenkins.io/doc/book/installing/linux/#long-term-support-release
Jenkins should start the background service. Alternatively you can also start the service by executing service start command
sudo systemctl start jenkins
Jenkins Admin UI Access
UI verification
Jenkins comes with a web application archive (aka .war) deployed. This webapp helps you access, customize and execute a jenkins pipeline using an graphical user interface (GUI). However you cannot access the ui from your ssh terminal. But it is worth checking the webapp is up and running by using curl against port 8080 which is the default port that runs jenkins.
curl http://localhost:8080
In the terminal you should see a basic html code that the server's home page sends back. With that you can confirm that jenkins is running and the admin web app is properly installed.
Access through web browser
Given that the application is running on an EC2, you have to manually open port 8080 to be accessed over the internet in the EC2 security group.
Security group changes
Login to your AWS console and navigate to EC2 home page.
AWS Console -> in Navbar search ec2 -> choose EC2
Choose your instance where you installed jenkins and in the bottom half of your screen choose the
Security Tab
that lists the security groups associated with this instance.On the Inbound rules tab, Choose
Edit inbound rules -> Add rule
For Type choose Custom TCP, For port type in
8080
, For Source, choose My IPSave and exit
This allows 8080 port to be accessed from your computer alone using HTTP protocol
Last step
- Open browser and using your ec2's public IP or DNS to open the jenkins admin page
http://ec2_DNS:8080/
- You'd be greeted with a nice UI interface that asks for the password
- The default password is protected and securely stored in a file in the jenks server.
- You can access the password by ssh into the ec2 again and view the file with command
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Copy that password and provided it in the browser's password box
We are all set!!
Top comments (0)