Jenkins can be installed using various methods, including:
- Tomcat Server
- Docker
- Vagrant
INSTALLING TOMCAT
To install Jenkins with Tomcat, ensure you have Java (minimum version 7) and Tomcat (minimum version 5). Here are the steps:
- For deploying Java 8 and Tomcat, Vagrant offers a preconfigured box. Initiate it using the commands below in your desired directory:
mkdir jenkins && cd jenkins
vagrant init emessiha/ubuntu64-java --box-version 1.0.0
vagrant up
These commands create a directory named jenkins and set up a Vagrant machine with Java 8 and Tomcat 9 installed.
INSTALLING JENKINS AS A SERVLET
Inside the Vagrant machine, download the war file:
wget http://ftpnyc.osuosl.org/pub/jenkins/war/2.69/jenkins.war
You can then deploy Jenkins alongside other servlets or as the default application on Tomcat. For the latter, follow these steps:
rm -rf /opt/tomcat/webapps/* && mv jenkins.war /opt/tomcat/webapps/ROOT.war
Navigate to http://localhost:8080 to begin Jenkins installation. The initialAdminPassword can be found at /home/ubuntu/.jenkins/secrets/.
INSTALLING JENKINS AS A STANDALONE SERVICE
Another option is to install Jenkins as a standalone service. Here’s how:
sudo wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo echo 'deb https://pkg.jenkins.io/debian-stable binary/' >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install jenkins
INSTALLING JENKINS USING THE WAR FILE
This method involves downloading the generic war file from jenkins.io:
wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
Start Jenkins by running:
java -jar jenkins.war
INSTALLING IN A DOCKER CONTAINER
For Docker installation:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
Then, pull the Jenkins image and run the container:
sudo docker pull jenkins
docker run -d -p 8080:8080 -v /home/vagrant/:/var/jenkins_home:z -t jenkins
Access Jenkins at localhost:8080 in your browser. This Docker command is platform-agnostic, offering flexibility and interoperability.