Skip to content

01_Jenkins_Setup

Abhishek Dubey edited this page Oct 19, 2020 · 10 revisions

Jenkins Setup

In this lab we will explore installing Jenkins:

  • Install Jenkins using the apt package manager.
  • Uninstall Jenkins.

Jenkins has a dependency on Java, please check if it is installed or not. If it is not installed install it by

sudo apt install default-jdk

Installation on Linux(Debian) System

First, add the key for Jenkins

 wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

Then add the repository to Debian source list

sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

Update the repositories

sudo apt update

Install the Jenkins

sudo apt install jenkins

Start the Jenkins service

sudo systemctl start jenkins

Access the service on http://<server_ip>:8080

You should see the Unlock Jenkins screen, which displays the location of the initial password:

In the terminal window, use the cat command to display the password:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

The next screen presents the option of installing suggested plugins or selecting specific plugins:

We’ll click the Install suggested plugins option, which will immediately begin the installation process:

Installing Maven

Maven needs to be installed for further tasks

sudo apt install maven

Advanced/Optional

Installing Jenkins using Docker

If you haven't installed the docker yet, you can install it by:-

sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
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 docker-ce-cli containerd.io

Once docker is installed we can create a Jenkins container

docker run --name jenkins-training -p 8080:8080 -p 50000:50000 -v /var/jenkins_home jenkins

Note:- 50000 port is for JNLP connection