Installing Jenkins Server & Slave on Linux Platforms

DevOps Company
3 min readMar 4, 2021

--

Jenkins AWS AMIs by Kurian for building robust CI/CD pipeline.

Complete Jenkins offerings by Kurian in AWS marketplace, that can be tried out for free.

When it comes to install an application on Linux distributions they look very different. You have to deal with multiple package management systems and installation steps that might not look much in common unfortunately. Here we would see how Jenkins software is installed on two representative Linux platforms, Ubuntu and CentOS.

Install Jenkins Server on Ubuntu

Following steps work on all the latest versions of Ubuntu — 16.06, 18.04 and 20.04

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

Install Jenkins Server on CentOS

The following steps work on both CentOS 7 and 8 with slight variations.

$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo$ sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key# Edit /etc/yum.repos.d/jenkins.repo and set 'gpgcheck=0'# On CentOS 7
$ sudo yum install jenkins -y
# On CentOS 8
$ sudo dnf install jenkins -y
# On CentOS firewall might be needed to make port 8080 open
# use following steps if needed.
$ sudo service firewalld start
$ sudo firewall-cmd --zone=public --add-port=8080/tcp
$ sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent

Install Jenkins Slave on Linux

Luckily the steps involved in setting a Jenkins slave host is generic on Linux platforms.

  • Create OS group “jenkins”.
  • Create OS user “jenkins” with: group “jenkins”, home directory “/var/jenkins” and shell “/bin/bash”.
  • Create “/var/jenkins/.ssh”
$ sudo mkdir /var/jenkins/.ssh
$ sudo chown jenkins:jenkins /var/jenkins/.ssh
$ sudo chmod 700 /var/jenkins/.ssh
  • Setup password-less sudo-as access for jenkins user
$ sudo echo "jenkins ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/jenkins-user

That’s pretty much you need to do on the slave host prior to adding it as a slave on a Jenkins server. Those configuration steps follow.

Jenkins Machine Images for AWS (AMI) by Kurian

If you are on Amazon AWS, Kurian provides Jenkins Server and Slave AMIs on all popular Linux distributions. All you need is to spin up required nodes and start using them immediately with very little configuration. The full list of AMIs currently available on AWS Marketplace is provided below for you to try out for free.

Jenkins Server AMIs

Jenkins Slave AMIs

Configure Jenkins Slave

There are multiple ways to add a slave node to Jenkins server:

  • Launch agent on slave node via SSH
  • Launch agent on slave by connecting it to the server
  • Automatically provisioned build nodes using Amazon EC2 plugin

All these 3 configuration methods are documented at https://github.com/kurianinc/ami-pub/wiki/Jenkins-Build-Slave-AMI-by-Kurian#configuration

Feel free to file a bug or a note about the information provided here if you run into issues.

--

--

DevOps Company
0 Followers

We provide building blocks and directions to kick start or fine tune your DevOps practice.