Install Jenkins on Ubuntu - Simple freestyle project
Step 1. Install jenkins on AWS EC2 Ubuntu instance.
Once Ubuntu instance is launched and is in running state, connect the
instance -Open a terminal window and update the system package
repository by running:
sudo apt update
sudo apt list –upgradable
Depending on which Java version you want to install, Java 8 or 17, run
one of the following commands:
sudo apt install openjdk-17-jre
check java version:
java -version
Step 2: Add Jenkins Repository
Jenkins repository to your Ubuntu system.
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-
2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
Add the Jenkins software repository to the source list and provide the
authentication key:
echo deb [signed-by=/usr/share/keyrings/jenkins-
keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
These commands add the Long-Term Support (LTS) stable release to
the sources list, but there is no output.
Step 3: Install Jenkins
Update the system repository one more time. Updating refreshes the
cache and makes the system aware of the new Jenkins repository.
sudo apt-get update
Install Jenkins by running:
sudo apt-get install Jenkins
To check if Jenkins is installed and running, run the following
command:
sudo systemctl start jenkins.service
sudo systemctl status jenkins
A bright green entry labelled active (running) should appear in the
output, indicating that the service is running.
For jenkins used port 8080, browse instance-public-IP/8080
it will open jenkins dashboard.
A page opens prompting you to Unlock Jenkins. Obtain the required
administrator password in the next step. Obtain the default Jenkins
unlock password by opening the terminal and running the following
command:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
It will take approximate 2 to 5 minutes and then next screen will come up
The setup prompts to either Install suggested plugins or Select
plugins to install. It’s fine to simply install the suggested plugins.
Creating a Jenkins freestyle project involves several steps:
Click on the “New Item” button on the left sidebar.
Give your project a name, such as “avik0418” and select “Freestyle
project” as the project type and press ok
In the configuration section, scroll down to the “Build” section and
add an “Execute shell” build step .
In the command field, enter the command to print “this is my first
jenkins pipeline”, such as echo “this is my first jenkins
pipeline”.
Click on the “Save” button at the bottom of the page to create the
project.
Once the project is created, click on the “Build Now” link to run the
project.
Check the console output for “this is my first jenkins
pipeline” message.