Beginner’s Guide: How To Install Jenkins on an EC2 Instance(Linux). Part 2.

Beginner’s Guide: How To Install Jenkins on an EC2 Instance(Linux). Part 2.

Download and install Jenkins

To switch to root user

[ec2-user ~]$ sudo su

To ensure that your software packages are up to date on your instance, use the following command to perform a quick software update:

[ec2-user ~]$ sudo yum update –y

Add the Jenkins repo using the following command:

[ec2-user ~]$ sudo wget -O /etc/yum.repos.d/jenkins.repo \

https://pkg.jenkins.io/redhat-stable/jenkins.repo

Import a key file from Jenkins-CI to enable installation from the package:

[ec2-user ~]$ sudo rpm — import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

[ec2-user ~]$ sudo yum upgrade

Install Java:

[ec2-user ~]$ sudo amazon-linux-extras

[ec2-user ~]$ install java-openjdk11 -y

Install Jenkins:

[ec2-user ~]$ sudo yum install jenkins -y

Enable the Jenkins service to start at boot:

[ec2-user ~]$ sudo systemctl enable jenkins

Start Jenkins as a service:

[ec2-user ~]$ sudo systemctl start jenkins

You can check the status of the Jenkins service using the command:

[ec2-user ~]$ sudo systemctl status jenkins

Configure Jenkins

Jenkins is now installed and running on your EC2 instance. To configure Jenkins:

~Connect to http://<your_server_public_DNS>:8080 from your favorite browser. You will be able to access Jenkins through its management interface:

No alt text provided for this image

As prompted, enter the password found in /var/lib/jenkins/secrets/initialAdminPassword.

Use the following command to display this password:

[ec2-user ~]$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

The Jenkins installation script directs you to the Customize Jenkins page. Click Install suggested plugins.

No alt text provided for this image

Once the installation is complete, Create First Admin User, click Save and Continue.

No alt text provided for this image

After you must have created the your account, it will be logged into jenkins dashboard.

Setup Java.

On the left-hand side, click Manage Jenkins, and then click Global Tool Configuration.

No alt text provided for this image

Go to the JDK section, Click on Add JDK, uncheck Install automatically, and then add your java path. Click Save.

No alt text provided for this image

Create your first Jenkins project

On the left-hand side, Click on New Item.

Name your project, Select freestyle project and click ok.

No alt text provided for this image

Click on Build Environment, in the build section click on Add build step select Execute shell. Type this code

echo “Welcome to my DevOps Journey!!!”

Click Save

No alt text provided for this image

Click on Build Now. Then click on #1

No alt text provided for this image

Hurray!!! We have successfully built our first ever Jenkins Project.

No alt text provided for this image

Let me know in the comment section if this article helped you, also let me know if you encounter any difficulties.

Thanks for Reading.


Great post. Jenkins is always a very good option

To view or add a comment, sign in

More articles by Henry Godwin

Others also viewed

Explore content categories