Jenkins is an open-source automation software widely used for continuous integration and deployment of applications. It serves as a server that automates complex tasks, allowing developers to focus on writing code. By running automated tests every time code is checked into a version control system, Jenkins ensures the reliability and quality of applications. In addition to its core functionality, Jenkins offers a wide range of capabilities, including deployment tasks, version control system integration, file system monitoring, and much more. In this guide, we will walk you through the process of installing and configuring Jenkins on an AlmaLinux 8 system, empowering you to leverage its powerful capabilities.
Prerequisites
Before we begin the installation process, make sure you have the following prerequisites in place:
- AlmaLinux 8: Ensure that you have AlmaLinux 8 installed on your server.
- SSH Access: You should have SSH access to your server to execute commands.
- Root Access: Root access is necessary to install Jenkins and perform certain tasks.
- Minimum Hardware Requirements: Make sure your server meets the minimum hardware requirements, including 1 GB of RAM, 10GB of free disk space, and a decent processor.
Updating the System
To ensure a smooth installation process, it’s essential to have an up-to-date system. Start by running the following commands to update your server:
sudo dnf update -y sudo dnf upgrade -y sudo dnf install epel-release
Installing Java
Since Jenkins is primarily written in the Java language, you need to have Java installed on your system. In this tutorial, we will use OpenJDK, a free and open-source implementation of Java SE. Execute the following command to install OpenJDK:
sudo dnf install java-1.8.0-openjdk -y
Once the installation is complete, verify the installed Java version by running the following command:
java-version
Adding Jenkins Repository
To download Jenkins, we need to add the Jenkins repository to our system. The official Jenkins site provides a popular repository that we can utilize. Follow the steps below to add the repository:
- Import the public PGP key used by the Jenkins official site to sign their files:
rpm --importhttps://pkg.jenkins.io/redhat-stable/jenkins.io.key
- Create a new source list named
jenkins.repo
in the/etc/yum.repos.d/
directory:
sudo tee /etc/yum.repos.d/jenkins.repo <<EOF [jenkins] name=Jenkins-stable baseurl=http://pkg.jenkins.io/redhat-stable gpgcheck=1 EOF
- Download the metadata for all the packages available in the newly added source list:
sudo dnf makecache
- Verify that the Jenkins repository has been added correctly:
sudo dnf repolist | grep jenkins
If you see a line containing “jenkins” in the output, it means the repository has been added successfully.
- Enable the Jenkins repository if it’s not already enabled:
sudo dnf config-manager --set-enabled Jenkins-stable
Installing Jenkins
Now that we have added the Jenkins repository, we can proceed with the installation. Execute the following commands to install Jenkins:
sudo dnf -y install jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkins
To verify the status of the Jenkins service, use the following command:
sudo systemctl status jenkins
If everything is fine, you should see a green “active (running)” status.
Configuring the Firewall
Jenkins runs on port 8080 by default. To allow access to the Jenkins service from external computers, you need to open port 8080 and allow remote connections. Execute the following commands to configure your firewall:
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp sudo firewall-cmd --reload
To verify that the firewall rules have been applied correctly, run the following command:
sudo firewall-cmd --list-all
Make sure there is a rule for port 8080 in the output.
Accessing Jenkins Web UI
Once Jenkins is installed and the firewall is configured, you can access the Jenkins web interface using your web browser. Enter the IP address or domain name of your server, followed by port 8080. For example, if the server’s IP address is 192.168.0.1, the URL would be http://192.168.0.1:8080.
You will be greeted with the Jenkins Getting Started page, which prompts you to enter an Administrator password. To retrieve the password, go back to your terminal and run the following command:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste it into the Administrator password field in the Jenkins web UI. Click the “Continue” button to proceed.
On the Customize Jenkins page, you can choose to install suggested plugins or select individual plugins manually. For newcomers, we recommend installing the suggested plugins, but advanced users can opt for manual selection. Once the plugin installation is complete, you will be prompted to create the first admin user. Provide a username, password, and email for the admin user and click the “Save and Finish” button.
On the Instance Configuration page, you can keep the default settings and click the “Save and Continue” button.
Finally, click on “Start using Jenkins” on the last page to access the Jenkins Dashboard, where you can start creating jobs and managing your Jenkins server.
Conclusion
Congratulations! You have successfully installed and configured Jenkins on your AlmaLinux 8 system. With Jenkins, you can now automate your continuous integration and deployment processes, ensuring the reliability and quality of your applications.
As you explore Jenkins further, you can customize its functionality, install additional plugins, and integrate it with your existing workflows. Jenkins offers a wide range of capabilities that can streamline your development process and improve productivity.
If you require any assistance with Jenkins or any other hosting-related services, Shape.host is here to help. Shape.host provides reliable and scalable cloud hosting solutions, including Cloud VPS, to empower businesses with efficient and secure hosting infrastructure. Visit Shape.host for more information and start harnessing the power of the cloud for your projects.