Please follow steps to install Java, Jenkins on Ubuntu EC2. Jenkins is a java-based application, so you need to install Java first.
Java Setup on Ubuntu
$ sudo apt-get update
Verify the Java version
$ sudo apt-get install openjdk-11-jdk -y not to ask for the runtime
type "Y" to continue installing java
Steps to install the Jenkins:
Introduction :
ubuntu@ip-172-31-41-76:~$ sudo apt-get update
Finally, install Jenkins and its dependencies:
Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.
Check
Note: If the firewall is inactive, the following commands will allow OpenSSH and enable the firewall:
Check
With Jenkins installed and our firewall configured, we can complete the initial setup.
Step 4: Setting Up Jenkins
To set up your installation, visit Jenkins on its default port,
You should see the Unlock Jenkins screen, which displays the location of the initial password:
========================================================================
This will help us in case of unable to connect with jenkins server
========================================================================
Note: if you are unable to connect Jenkins server with your public ip address or hostname like the above image, then follow the below steps
We’ll click the Install suggested plugins option, which will immediately begin the installation process:
When the installation is complete, you will be prompted to set up the first administrative user. It’s possible to skip this step and continue as using admin the initial password we used above, but we’ll take a moment to create the user and click on Save and Continue.
Enter the name and password for your user:
You will see an Instance Configuration page that will ask you to confirm the preferred URL for your Jenkins instance. Confirm either the domain name for your server or your server’s IP address:
After confirming the appropriate information, click Save and Finish. You will see a confirmation page confirming that “Jenkins is Ready!”:
Click Start using Jenkins to visit the main Jenkins dashboard:
At this point, you have completed a successful installation of Master Jenkins.
Java Setup on Ubuntu
To install this version, first update the package index:
$ sudo apt-get update
Verify the Java version
Installing Specific Versions of OpenJDK
Java 11 is the current Long Term Support version and is still widely supported, though public maintenance ends at least September 2022 for AdoptOpenJDK. To install OpenJDK 8, execute the following command:
type "Y" to continue installing java
Verify that this is installed with and You’ll see output like this:
$ java -version
Steps to install the Jenkins:
Introduction :
Jenkins is an open-source automation server that automates the repetitive technical tasks involved in the continuous integration and delivery of software. Jenkins is Java-based and can be installed from Ubuntu packages or by downloading and running its web application archive (WAR) file — a collection of files that make up a complete web application to run on a server.
Step 1: Intalling Jenkins
First, add the repository key to the system:
$ wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
When the key is added, the system will return
OK
. like in the below image
Next, append the Debian package repository address to the server’s
sources.list
:
$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
When both of these are in place, run
update
so that apt
will use the new repository:Finally, install Jenkins and its dependencies:
Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.
Step 2: Starting Jenkins
Let’s start Jenkins using
systemctl
:
ubuntu@ip-172-31-41-76:~$ sudo systemctl start jenkins
Since
systemctl
doesn’t display output, you can use its status
command to verify that Jenkins started successfully:
If everything went well, the beginning of the output should show that the service is active and configured to start at boot:
Now that Jenkins is running, let’s adjust our firewall rules so that we can reach it from a web browser to complete the initial setup.
Step 2: Opening the Firewall
By default, Jenkins runs on port
8080
, so let’s open that port using ufw
:ufw
’s status to confirm the new rules:Note: If the firewall is inactive, the following commands will allow OpenSSH and enable the firewall:
Check
ufw
’s status again to confirm With Jenkins installed and our firewall configured, we can complete the initial setup.
Step 4: Setting Up Jenkins
To set up your installation, visit Jenkins on its default port,
8080
, using your server domain name or IP address: http://your_server_ip_or_domain:8080
Eg : http://3.15.210.35:8080
You should see the Unlock Jenkins screen, which displays the location of the initial password:
========================================================================
This will help us in case of unable to connect with jenkins server
========================================================================
Note: if you are unable to connect Jenkins server with your public ip address or hostname like the above image, then follow the below steps
It seems you have not opened your 8080 port in Security Groups in AWS.
Steps:
- Go to AWS console
- Click
Security Group
and select the security group that you have assigned to your EC2 instance. - Click
Edit Inbound Rules
- Add a
Custom TCP Rule
and add8080
in thePort Range
.
5. You will now see Jenkins rise from the grave :) i.e. first-time installation screen.
==========================================================================
In the terminal window, use the
cat
command to display the password:
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the 32-character alphanumeric password from the terminal and paste it into the Administrator password field, then click Continue.
The next screen presents the option of installing suggested plugins or selecting specific plugins:
When the installation is complete, you will be prompted to set up the first administrative user. It’s possible to skip this step and continue as using admin the initial password we used above, but we’ll take a moment to create the user and click on Save and Continue.
Enter the name and password for your user:
You will see an Instance Configuration page that will ask you to confirm the preferred URL for your Jenkins instance. Confirm either the domain name for your server or your server’s IP address:
After confirming the appropriate information, click Save and Finish. You will see a confirmation page confirming that “Jenkins is Ready!”:
Click Start using Jenkins to visit the main Jenkins dashboard:
At this point, you have completed a successful installation of Master Jenkins.