How to Install Jenkins on Amazon Linux 2

In this article we are going to cover How to install java on Amazon Linux 2, How to Install Jenkins on Amazon Linux 2,How to configure jenkins on Amazon Linux 2,completely Remove Jenkins from amazon Linux 2.

What is Jenkins ?

Jenkins is an open-source automation server that is commonly used for continuous integration (CI) and continuous delivery (CD) processes in software development. It allows developers to automate various aspects of the software development lifecycle, including building, testing, and deploying applications. Jenkins is written in Java and provides a web-based interface for managing and configuring automated tasks.

Key features of Jenkins:

  • Automation: Jenkins can automate various tasks such as building code, running tests, deploying applications which helps reduce manual work and potential errors, and more. It can be configured to trigger these tasks automatically when code changes are pushed to a version control system (e.g., Git).
  • Extensibility: Jenkins has a large and active community that develops and maintains numerous plugins, making it easy to extend and customize its functionality to suit specific project needs.
  • Scalability: Jenkins can be distributed across multiple nodes or machines, allowing you to scale your CI/CD infrastructure as needed.
  • Community Support: Jenkins has a large and active community of users and contributors who provide support, share plugins, and contribute to its development.
  • Security: ┬áJenkins offers security features to protect the automation server and the code it manages, including user authentication, access control, and encryption.
  • Monitoring and Reporting: Jenkins provides detailed logs, reports, and notifications to help developers track the progress of their builds and deployments, as well as identify and address any issues that may arise.
  • Pipeline Support: Jenkins supports the creation of continuous integration/continuous delivery (CI/CD) pipelines, which define the sequence of steps required to build, test, and deploy software using a domain-specific language called Jenkins Pipeline. This allows you to define your entire CI/CD process as code, making it easier to version control and manage.

Jenkins has been widely adopted in the software development industry because of its flexibility, extensibility, and the support it provides for automating essential DevOps processes. It helps development teams deliver software more efficiently and with fewer errors by automating and orchestrating key tasks throughout the software development lifecycle.

Prerequisites

  • Amazon Linux 2 instance
  • Atleast 1 GB RAM
  • JDK 1.8 or Higher version is supported
  • Open Port 8080

How to Download and install Jenkins on Amazon Linux 2

Step #1:How to install java on Amazon Linux 2

updates all installed software packages on your Amazon Linux 2 instance

sudo yum update

installs OpenJDK 11 on your Amazon Linux 2 instance, which is required for Jenkins to run.

sudo amazon-linux-extras install java-openjdk11 -y

Step #2:How to Install Jenkins on Amazon Linux 2

adds the Jenkins repository to your system, allowing you to install Jenkins

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
jenkin repo

imports the Jenkins-CI GPG key, which is used to verify the authenticity of Jenkins packages during installation.

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

upgrades any installed packages to their latest versions.

sudo yum upgrade

installs Jenkins on your Amazon Linux 2 instance.

sudo yum install jenkins -y
install jenkin

Step #3:Start Jenkins Service on Amazon Linux 2

Enable Jenkins Service To configures Jenkins to start automatically when your system boots up.

sudo systemctl enable jenkins

starts the Jenkins service immediately

sudo systemctl start jenkins
enable n start

To verify the status of the Jenkins service and check if it’s running without any issues.

sudo systemctl status jenkins
jenkin status

Step #4:How to configure jenkins on Amazon Linux 2

Access Jenkins Web Interface: Open a web browser and navigate to the Jenkins web interface using your Amazon Linux 2 instance’s public IP address and port 8080. Replace <your_server_public_IP> with your actual server’s public IP address.http://123-45-67-89:8080

Unlock Jenkins: On your first visit, Jenkins will require you to unlock it to set up the initial administrator password. You can find this password in a file on your Amazon linux 2 instance.

unlock jenkin

To retrieve it, SSH into your EC2 instance using the appropriate credentials and run the following command to print the password:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
password

Copy the generated password from the terminal and Return to the Jenkins web interface in your browser and paste the unlock key into the “Administrator password” field. Then, click “Continue.”

pwd to unlock j

Customize Jenkins:You will be given options to install suggested plugins or select specific plugins. You can choose either option based on your requirements. Installing suggested plugins is a good start for most users.

customized jenkin

Create an Admin User: After the plugins are installed, you will be prompted to create an admin user. Fill in the required information, such as username, password, full name, and email address. Or you can click on skip and continue as admin.

create first user

Instance Configuration: Configure the URL for Jenkins, which is typically derived automatically. You can leave it as the default unless you have specific requirements.

instnce congifn

Click “Save and Finish” to complete the setup.

You will see a “Start using Jenkins” button.

start jenkin

you can see Dashboard of Jenkins

jenkin dashboard

Now, Jenkins is configured and ready to use on your Amazon Linux 2 instance. You can start creating and configuring Jenkins jobs and pipelines for your projects. Make sure to secure your Jenkins instance further by following best practices, such as restricting access, setting up authentication, and configuring security settings as needed for your environment.

We have covered How to Install Jenkins on Amazon Linux 2.

How to completely Remove Jenkins from amazon Linux 2 (Optional Step)

To remove Jenkins from an Amazon Linux 2 instance, you can use the following commands. These commands will uninstall Jenkins and its associated files:

Stop the Jenkins service (if it’s running):

sudo systemctl stop jenkins
stop jenkin

        Remove the Jenkins package:

sudo yum remove jenkins
remove jenkin

Remove the Jenkins configuration and data:

sudo rm -rf /var/lib/jenkins

Remove the Jenkins repository file:

sudo rm -f /etc/yum.repos.d/jenkins.repo

If you imported the Jenkins GPG key during installation, you can remove it as well:

sudo rpm -e jenkins.io

Clean the Yum cache to remove any residual files:

sudo yum clean all

Jenkins should now be completely removed from your Amazon Linux 2 instance. Make sure to review the list of packages that yum wants to remove before confirming the removal to ensure that there are no unexpected dependencies being removed.

Conclusion:

In this article we have covered How to install java on Amazon Linux 2, How to Install Jenkins on Amazon Linux 2,How to configure jenkins on Amazon Linux 2,completely Remove Jenkins from amazon Linux 2.

Related Articles:

YAML Basic Tutorial with Examples

About Priti Adkine

I am Priti Adkine working as Software Engineer and having 1+ years of Experience. Likes to share knowledge.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link