Install Jenkins on Debian/Ubuntu

print

Debian/Ubuntu

https://www.jenkins.io/doc/book/installing/#debianubuntu

On Debian and Debian-based distributions like Ubuntu you can install Jenkins through apt.

6 java -version
297 systemctl status jenkins
298 systemctl enable jenkins
299 sudo systemctl enable jenkins
300 systemctl status jenkins
301 systemctl restart jenkins
302 sudo systemctl restart jenkins
303 systemctl status jenkins
304 cat /var/lib/jenkins/secrets/initialAdminPassword
305 sudo cat /var/lib/jenkins/secrets/initialAdminPassword
306 sudo systemctl restart jenkins

Long Term Support release

LTS (Long-Term Support) release is chosen every 12 weeks from the stream of regular releases as the stable release for that time period. It can be installed from the debian-stable apt repository.

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
    /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
Weekly release

A new release is produced weekly to deliver bug fixes and features to users and plugin developers. It can be installed from the debian apt repository.

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian binary/ > \
    /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
If an error is reported, “jenkins : Depends: daemon but it is not installable”, add the “universe” apt repository of community maintained free and open source software for Ubuntu by executing this command after sudo apt-get update:sudo add-apt-repository universe

This package installation will:

  • Setup Jenkins as a daemon launched on start. See /etc/init.d/jenkins for more details.
  • Create a ‘jenkins’ user to run this service.
  • Direct console log output to the file /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.
  • Populate /etc/default/jenkins with configuration parameters for the launch, e.g JENKINS_HOME
  • Set Jenkins to listen on port 8080. Access this port with your browser to start configuration.
If your /etc/init.d/jenkins file fails to start Jenkins, edit the /etc/default/jenkins to replace the line ----HTTP_PORT=8080---- with ----HTTP_PORT=8081---- Here, “8081” was chosen but you can put another port available.
Installation of Java

Jenkins requires Java in order to run, yet certain distributions don’t include this by default and some Java versions are incompatible with Jenkins.

There are multiple Java implementations which you can use. OpenJDK is the most popular one at the moment, we will use it in this guide.

To install the Open Java Development Kit (OpenJDK) run the following:

  • Update the repositories
sudo apt update
  • search of all available packages:
sudo apt search openjdk
  • Pick one option and install it:
sudo apt install openjdk-8-jdk
  • Confirm installation:
sudo apt install openjdk-8-jdk
  • checking installation:
java -version
  • the result must be something like:
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
Why use apt and not apt-get or another command? The apt command has been available since 2014. It has a command structure that is similar to apt-get but was created to be a more pleasant experience for typical users. Simple software management tasks like install, search and remove are easier with apt.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.