In this Guide we are going to learn how to install and configure Jenkins in Fedora 35.
Jenkins is a popular open source automation tool to perform continuous integration and build automation. Jenkins allows to execute a predefined list of steps, e.g. to compile golang source code to build build binary file. The trigger for this execution can be time or event based.
Possible steps executed by Jenkins are for example:
- Cloning the code from source control system.
- execute a command to install dependencies required for the code to run
- Run tests for the software
- build the software to get an executable
- Publish test results
- publish the resulting binary code
Jenkins monitors the execution of the steps and allows to stop the process, if one of the steps fails. Jenkins can also send out notifications in case of a build success or failure.
Jenkins can be extended by additional plug-ins. For example, you can install plug-ins to support building and testing Android applications.
- How to Install and set up Jenkins on Ubuntu 20.04
- How to install and set up Jenkins in Rocky Linux/Centos 8
- A Linux system with Fedora 35 server (At least 2GB of Ram)
- A user account with sudo or root privileges
- Access to a terminal window/command line
- Recent Java version installed
Table of content
- Ensuring that the system is up to date
- Install Java
- Install Jenkins
- Starting and enabling jenkins
- Accessing Jenkins
- Optional – Using an Ansible playbook
1. Ensuring that the system is up to date
Ensure that the system packages are up to date using this command:
sudo dnf -y update
2. Install Java
In this section, we will install java on our system. We will be using the openjdk version of java. In Fedora, to check what software provides the java command line, use the following command:
dnf whatprovides java
$ sudo dnf whatprovides java Last metadata expiration check: 1:44:05 ago on Sat 06 Nov 2021 02:35:55 PM UTC. java-11-openjdk-1:184.108.40.206.9-0.fc34.x86_64 : OpenJDK 11 Runtime Environment Repo : fedora Matched from: Provide : java = 1:220.127.116.11.9-0.fc34 java-11-openjdk-1:18.104.22.168.8-1.fc34.i686 : OpenJDK 11 Runtime Environment Repo : updates Matched from: Provide : java = 1:22.214.171.124.8-1.fc34 java-11-openjdk-1:126.96.36.199.8-1.fc34.x86_64 : OpenJDK 11 Runtime Environment Repo : updates Matched from: Provide : java = 1:188.8.131.52.8-1.fc34
We can see that it is provided by the
java-1.8.0-openjdk-1:184.108.40.2065.b01-1.el8_3.x86_64. Install it using the command
sudo dnf install <meta charset="utf-8">java-11-openjdk
3. Install Jenkins
Add jenkins repository
Jenkins isn’t included in the default CentOS software repositories. Use the following commands to add and import the GPG key to ensure your software is legitimate.
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
You can check the presence of the repo using this command:
$ dnf repolist repo id repo name ... jenkins Jenkins ...
Use the following command to install the latest stable build of jenkins:
sudo dnf install jenkins
4. Starting and enabling jenkins
Now that jenkins is installed, we ca start it:
# /etc/init.d/jenkins start Starting jenkins (via systemctl): [ OK ]
To display the status of the Jenkins service, enter the following:
# /etc/init.d/jenkins status ● jenkins.service - LSB: Jenkins Automation Server Loaded: loaded (/etc/rc.d/init.d/jenkins; generated) Active: active (running) since Sat 2021-11-06 16:48:36 UTC; 10s ago Docs: man:systemd-sysv-generator(8) Process: 28820 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS) Tasks: 48 (limit: 4603) Memory: 1.1G CPU: 19.365s CGroup: /system.slice/jenkins.service └─28825 /etc/alternatives/java -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/j> Nov 06 16:48:36 ip-10-2-40-10.us-west-2.compute.internal systemd: Starting LSB: Jenkins Automation Server... Nov 06 16:48:36 ip-10-2-40-10.us-west-2.compute.internal jenkins: Starting Jenkins [ OK ] Nov 06 16:48:36 ip-10-2-40-10.us-west-2.compute.internal systemd: Started LSB: Jenkins Automation Server.
Please check to ensure that the status is
active (running) to know that the installation was successful.
Enable Jenkins in firewalld
You also need to add Jenkins service to run with firewall and add its exception so that it is available to access from the outside world. Finally, we need to reload the firewall service for the changes to take effect.
<strong>#</strong> firewall-cmd --add-port=8080/tcp --permanent <strong>#</strong> firewall-cmd --reload
To check the firewall status and accessible ports, use the
<strong>#</strong> firewall-cmd --list-all
Now, the Jenkins server will be running on port 8080 for our server.
5. Accessing the jenkins server
Once installed, open browser and navigate to the jenkins on the url
http://127.0.0.1:8080/. If you are running on a remote server, replace the ip
127.0.0.1 with that server’s ip.
You will be asked to provide an initial password found in this location
/var/lib/jenkins/secrets/initialAdminPassword. Get it by running this command on the server.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
From here choose whether you want to install the recommended plugins or choose what you want to install.
The last page will allow you to set up some initial configuation for the user who will be using the jenkins server.
We managed to install Jenkins in a Fedora server in this guide.