Jenkins is an open-source automation server widely used for continuous integration and continuous delivery (CI/CD) pipelines. It simplifies the process of building, testing, and deploying software projects. Installing Jenkins on Ubuntu 22.04 is straightforward and can be accomplished in just a few steps.
Prerequisites
Before installing Jenkins, ensure you have the following prerequisites:
- A server or virtual machine running Ubuntu 22.04.
- Access to a terminal with sudo privileges.
Commands
$ sudo apt-get update -y && sudo apt-get upgrade -y
$ sudo systemctl enable apache2 && sudo systemctl start apache2
$ sudo systemctl status apache2
$ sudo apt install openjdk-11-jdk -y
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 install jenkins -y
$ sudo systemctl status jenkins
$ cd /etc/apache2/sites-available/
$ sudo nano jenkins.conf
======================================================================
<Virtualhost *:80>
ServerName yourdomain.com
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8080/*>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
ProxyPassReverse / http://yourdomain.com/
</Virtualhost>
=============================================================================
$ sudo a2ensite jenkins
$ sudo a2enmod proxy
$ sudo a2enmod proxy_http
$ sudo a2enmod headers
$ sudo systemctl restart apache2
cat /var/lib/jenkins/secrets/initialAdminPassword