Jenkins Setup

Jenkins can be installed on all operating systems/distributions, and is made easier with their docker container. I will be installing it on an Ubuntu server as we have done in the GitLab section previous though. Docs for reference.

Jenkins also has a list of best practices which I advise you explore and set up according to your organisation or environment.

Module Objectives

  • Install Jenkins Server

  • Install plugins

  • Create your First Admin Account

Prerequisites

Minimum:
- 4GB RAM
- 64GB Disk Space
- Virtualisation Software (VMWare or VirtualBox)
- Any Platform/OS
- Git
- Java JDK 17 / 22

For a more in-depth list - check the documentation

Installing Jenkins

Installing Jenkins is straightforward - the commands below were taken from the Jenkins documentation found here. I converted it to a script for convenience (and future automation).

https://github.com/Securescape/Offensive-Development/blob/main/Install%20Scripts/install_jenkins.sh
#!/bin/bash
###################
# Install Jenkins #
###################

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \
  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins -y

################
# Install Java #
################

sudo apt update
sudo apt install fontconfig openjdk-17-jre -y
java -version

#################
# Miscellaneous #
#################

# Quality of Life stuff
sudo apt install zsh -y
chsh -s $(which zsh)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh
echo "[!] SSH into your VM for the best experience."

############################
# Enable and Start Jenkins #
############################

sudo systemctl enable jenkins
sudo systemctl start jenkins

echo "[+] Installation Complete"
echo "[!] Jenkins running on: http://$(hostname -I | cut -d " " -f 1):8080"
echo "[!] Jenkins Password  : $(sudo cat /var/lib/jenkins/secrets/initialAdminPassword)"

Save the file as whatever you'd like, then execute it to begin the installation process. This can take several minutes to complete. Once done, you should see this output

[+] Installation Complete
[!] Jenkins running on: http://YOUR-IP:8080
[!] Jenkins Password  : 9d2ad[..]c2c43e

Access the webpage from the IP address selected, then use the password that was generated for you (You must change this later). You should see the page below when the password has been entered

Jenkins Initial Customisation

I'll click on the suggested plugins, though you can go with the other option as well. After the setup is complete, create your first admin user to access the main dashboard.

First Admin User

Create Admin User

If you are using a DNS server and custom SSL certs or a FQDN, you can also specify that URL here instead of the IP address (For simplicity, I'll go with the default value)

URL Setup

You should be taken to this screen once you've made your choice (skip or set the URL settings)

Main Dashboard
Missing Agent Error

You will also notice an error on the top right, this is due to us not having a build agent which we'll set up later.

Last updated