Debug School

Cover image for Install Jenkins
Suyash Sambhare
Suyash Sambhare

Posted on

Install Jenkins

Choose the Jenkins installer for your distro

  • Debian/Ubuntu
  • Fedora
  • Red Hat/Alma/Rocky

Preconditions

Bare minimum hardware requirements:

  • 256 MB RAM
  • 1 GB disk

Advised hardware configuration:

  • 4 GB+ RAM
  • 50 GB+ drive space

Software requirements:

  • Java
  • Web browser

Install Jenkins

An LTS (Long-Term Support) release is picked every 12 weeks from the tributary of steady releases as the stable release for that cycle. It can be set up from the Debian-stable apt source.

curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
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
Enter fullscreen mode Exit fullscreen mode

The bundle is set up with systemdrather than the former System V init. It will:

  • Set up Jenkins as a daemon started on bootup. Run systemctl cat jenkins for more information.
  • Create a ‘Jenkins’ user to run this service.
  • Redirect console log output to systemd-journald. Run journalctl -u jenkins.service for troubleshooting Jenkins.
  • Fill /lib/systemd/system/jenkins.service with configuration parameters for the start, e.g JENKINS_HOME
  • Set Jenkins to snoop on port 8080. Open this port with the browser to start configuration.
  • If Jenkins fails to start because a port is in use, run systemctl edit jenkins and add the next:
[Service]
Environment="JENKINS_PORT=8081"
Enter fullscreen mode Exit fullscreen mode

Install Java

Jenkins requires Java to run. Some Linux distributions do not include Java by default. And for those who do, not all Java versions are compatible with Jenkins.
Use OpenJDK at the moment.

Update the Debian apt sources, install OpenJDK 21, and confirm the installation with the commands:

sudo apt update
sudo apt install fontconfig openjdk-21-jre
java -version
openjdk version "21.0.8" 2023-09-18
OpenJDK Runtime Environment (build 21.0.8+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 21.0.8+7-Debian-1deb12u1, mixed mode, sharing)
Enter fullscreen mode Exit fullscreen mode

Satpura

Start Jenkins

Enable the Jenkins service to start at bootup:
sudo systemctl enable jenkins

Start the Jenkins service:
sudo systemctl start jenkins

Check the status of the Jenkins service:

sudo systemctl status jenkins
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-11-13 16:19:01 +03; 4min 57s ago
Enter fullscreen mode Exit fullscreen mode

Update Firewall

Add Jenkins as an exemption. Port 8080is the most common.

YOURPORT=8080
PERM="--permanent"
SERV="$PERM --service=jenkins"

firewall-cmd $PERM --new-service=jenkins
firewall-cmd $SERV --set-short="Jenkins ports"
firewall-cmd $SERV --set-description="Jenkins port exceptions"
firewall-cmd $SERV --add-port=$YOURPORT/tcp
firewall-cmd $PERM --add-service=jenkins
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
Enter fullscreen mode Exit fullscreen mode

Setup wizard

After downloading, installation, and execution of Jenkins, the post-installation setup wizard begins.
This setup wizard takes few quick steps to unlock Jenkins, customize it with plugins, and create the first admin user through which user can continue accessing Jenkins.

Unlock Jenkins
At the first access of a new Jenkins instance, user is asked to unlock it using an auto-generated password.
Browse to http://hostname:8080
From the Jenkins console log output, copy the auto-generated alphanumeric password.

Note: The command: sudo cat /var/lib/jenkins/secrets/initialAdminPassword will print the password at the console.
On the Unlock Jenkins page, paste this password into the Administrator password field and click Continue.
Note: The Jenkins console log indicates the location (in the Jenkins home directory) where this password can also be obtained. This password must be entered in the setup wizard on new Jenkins installations before user can access Jenkins’s main UI. This password also serves as the default administrator account’s password (with username "admin") if user happens to skip the subsequent user-creation step in the setup wizard.

Install Plugins

After unlocking Jenkins, the Customize Jenkins page appears. Install any number of useful plugins as part of the initial setup.
Click one of the two options shown:

  • Install suggested plugins - install the recommended set of plugins, which are based on the most common use cases.
  • Select plugins to install - to choose which set of plugins to initially install. When the user first access the plugin selection page, the suggested plugins are selected by default.

Choose Install suggested plugins. Install (or remove) additional Jenkins plugins at a later point in time via the Manage Jenkins > Plugins page in Jenkins.
The setup wizard shows the progression of Jenkins being configured and the chosen set of Jenkins plugins being installed. This process may take a few minutes.

Create Admin User

Finally, after customizing Jenkins with plugins, Jenkins asks to create the first administrator user.
When the Create First Admin User page appears, specify the details for your administrator user in the respective fields and click Save and Finish.
When the Jenkins is ready page appears, click Start using Jenkins.
Note: This page may indicate Jenkins is almost ready! instead and if so, click Restart.
If the page does not automatically refresh after a minute, use the web browser to refresh the page manually.
If required, login to Jenkins with the credentials of the user created.

Hooray! You are ready to start using Jenkins! 👍✨👨🏽‍🚀

Ref: https://www.jenkins.io/doc/book/installing/linux/

Top comments (0)