How to install and Configure Jenkins in OpenSUSE Leap 15

Jenkins is an open source automation server which enables developers around the world to reliably build, test, and deploy their software. It 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.

In this guide we are going to explore how to install and set up Jenkins in OpenSUSE Leap 15.3 server.

# Requirements

  • A Linux system with Opensuse leap 15.3 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: Accessing jenkins using a domain

# 1. Ensuring that the system is up to date

Before proceeding, ensure that your system has updated packages. Use this command to achieve this:

sudo zypper ref
sudo zypper update -y

# 2. Install Java

Jenkins required java runtime to work. We need to ensure that java is installed and working as expected beefore proceeding. Type this command to check the java version

java -version

If that command results in an error, you need to install java runtime environment. Use this command:

sudo zypper install dejavu-fonts fontconfig java-1_8_0-openjdk

Confirm the installed Java version with this command:

~> java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-suse-3.68.1-x8664)
OpenJDK 64-Bit Server VM (build 11.0.13+8-suse-3.68.1-x8664, mixed mode)

Checkout this article on How to install Java 17 in OpenSUSE Leap 15.3.

# 3. Install Jenkins

Jenkins uses System V init scripts to manage the service. insserv is used enable System V init scripts. This package only contains a stub implemenation for use on systemd only systems.

sudo zypper install insserv-compat

Jenkins is not available in the default Opensuse repositories. Add Jenkins repositories using this command:

sudo zypper addrepo -f https://pkg.jenkins.io/opensuse-stable/ jenkins

Update your local package index, then finally install Jenkins:

sudo zypper install jenkins

# 4. Starting and enabling jenkins

One installed, the service will need to be started. Use this command:

sudo systemctl start jenkins

Ensure that jenkins is running as expected by checking the systemd service status. You should see something like this:

~> sudo systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
     Loaded: loaded (/etc/init.d/jenkins; generated)
     Active: active (exited) since Mon 2022-02-28 11:49:26 UTC; 13s ago
       Docs: man:systemd-sysv-generator(8)

Feb 28 11:49:26 opensusesrv systemd[1]: Starting LSB: Jenkins Automation Server...
Feb 28 11:49:26 opensusesrv su[20720]: (to jenkins) root on none
Feb 28 11:49:26 opensusesrv su[20720]: pam_unix(su-l:session): session opened for user jenkins by (uid=0)
Feb 28 11:49:26 opensusesrv su[20720]: pam_unix(su-l:session): session closed for user jenkins
Feb 28 11:49:26 opensusesrv jenkins[20703]: Starting Jenkins ..done
Feb 28 11:49:26 opensusesrv systemd[1]: Started LSB: Jenkins Automation Server.

To ensure that the service is started on boot, enable it:

sudo systemctl enable jenkins

# Step 5. Enable Jenkins through firewall

Is you have firewalld installed and enabled, you will need to allow jenkins. Jenkins uses port 8080 so let us enable it and also the http port.

firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-service=http,https --permanent
firewall-cmd --reload

# Step 6. Accessing Jenkins

Access the jenkins server using the public ip on port 8080. If you are accessing the jenkins server locally, use http://localhost:8080

Get the jenkins public ip

curl -4 icanhazip.com

You can then navigate to http://public_ip:8080

# 6. Optional: Accessing jenkins using a domain name

If you want to access jenkins using a domain name, you can use something like nginx to proxy traffic. Nginx allows you to proxy the traffic and terminate ssl if need be.

Install nginx

sudo zypper install -y nginx

Ensure that nginx is running

sudo systemctl status nginx

Create an nginx server for jenkins in /etc/nginx/conf.d with the content to serve:

File /etc/nginx/conf.d/jenkins.conf

server {
    listen 80;
    listen [::]:80;
    server_tokens off;
    server_name your.domain.com;

    ## Deny illegal Host headers
    if ($host !~* ^(your.domain.com)$ ) {
        return 444;
    }

    location / {
          proxy_pass http://127.0.0.1:8080;
          proxy_set_header   Host $host;
          proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header   X-Forwarded-Host $server_name;
          proxy_set_header   X-Real-IP $remote_addr;
          proxy_set_header   X-Scheme $scheme;
          proxy_connect_timeout 60s;
          proxy_send_timeout 60s;
          proxy_read_timeout 60s;
    }
}

Restart nginx:

sudo systemctl restart nginx

Map the A record of the domain your.domain.com to the IP address of your server and you should be able to access it using http://your.domain.com

# 7. Configuring jenkins

The first time you access the jenkins server using the domain, you will be greeted with a getting started screen asking you to Unlock jenkins with an admin password from this path /var/lib/jenkins/secrets/initialAdminPassword in the server.

Get the pasword by typing this

cat /var/lib/jenkins/secrets/initialAdminPassword

Citizix - Jenkins install unlock

Citizix – Jenkins install unlock

Upon entering the password, you will be taken to plugin install page. You have an option of installing common plugins or choosing what plugins to install.

I always prefer to custom pick plugins I want installed so I have control on what plugins are installed and what not.

Citizix - Cuztomize jenkins

Citizix – Cuztomize jenkins

Once the plugin installation is done, you will be redirected to a page to create Jenkins First User. I always create an Admin user then choose a strong password.

Citizix - Jenkins Create First Admin User

Citizix – Jenkins Create First Admin User

After that Ensure the correct URL is set in the last page of the instance configuration page. After this you will be redirected to the jenkins dashboard page.

From here you can Create jenkins jobs and use jenkins as you would want.

Last updated on Mar 20, 2024 17:19 +0300
comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy