How to install and set up Jenkins in Fedora 35

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.

# Requirements

  • 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

  1. Ensuring that the system is up to date
  2. Install Java
  3. Install Jenkins
  4. Starting and enabling jenkins
  5. Accessing Jenkins
  6. 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:11.0.10.0.9-0.fc34.x86_64 : OpenJDK 11 Runtime Environment
Repo        : fedora
Matched from:
Provide    : java = 1:11.0.10.0.9-0.fc34

java-11-openjdk-1:11.0.13.0.8-1.fc34.i686 : OpenJDK 11 Runtime Environment
Repo        : updates
Matched from:
Provide    : java = 1:11.0.13.0.8-1.fc34

java-11-openjdk-1:11.0.13.0.8-1.fc34.x86_64 : OpenJDK 11 Runtime Environment
Repo        : updates
Matched from:
Provide    : java = 1:11.0.13.0.8-1.fc34

We can see that it is provided by the java-1.8.0-openjdk-1:1.8.0.275.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
...

# Install 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[1]: Starting LSB: Jenkins Automation Server...
Nov 06 16:48:36 ip-10-2-40-10.us-west-2.compute.internal jenkins[28820]: Starting Jenkins [  OK  ]
Nov 06 16:48:36 ip-10-2-40-10.us-west-2.compute.internal systemd[1]: 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 firewall-cmd command:

<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.

Citizix – Jenkins initial Password

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.

# Conclusion

We managed to install Jenkins in a Fedora server in this guide.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy