Installing Jenkins

Apr 16, 2017

Length: 09:15

1. Install Jenkins

We'll login using my local AWS-generated ssh key:

ssh -i ~/.ssh/fideloperllc.pem ubuntu@<server-ip>

Then we start installing:

# Install some Basics:
sudo apt-get update
sudo apt-get install -y vim curl wget tmux unzip htop ntp software-properties-common

# Install Jenkins
wget -q -O - | sudo apt-key add -
echo 'deb binary/' | sudo tee /etc/apt/sources.list.d/jenkins.list
sudo apt-get update
sudo apt-get install -y jenkins

# Status (Start Jenkins if necessary)
sudo service jenkins status

# Test It
curl localhost:8080

2. Install Nginx

We can view this in a browser yet, since port 8080 isn't publicly accessible from this server. Let's install Nginx and use that as our HTTP entry point for this. It will proxy requests over to Jenkins.

sudo add-apt-repository -y ppa:nginx/stable
sudo apt-get update
sudo apt-get install -y nginx

Configure Nginx

sudo rm /etc/nginx/sites-enabled/default
sudo vim /etc/nginx/sites-available/jenkins

Make it like so:

server {
    listen 80 default_server;
    server_name localhost;

    location / {
        proxy_pass              http://localhost:8080;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout   150;
        proxy_send_timeout      100;
        proxy_buffers           4 32k;
        client_max_body_size    8m;
        client_body_buffer_size 128k;

Then enable it:

sudo ln -s /etc/nginx/sites-available/jenkins \

Test and reload Nginx:

sudo service nginx configtest
sudo service nginx reload

Jenkins should now be web accessible!

3. Unlock Jenkins

Follow the steps to unlock Jenkins:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  1. Use that password in the browser to create a new user.
  2. Install suggested plugins.

Note the GitHub Organization Folder Plugin plugin, the Git plugin, and pipeline viewerplugin.

New Jenkins User

  • fideloper
  • Some Password

4. Docker

We'll use Docker on this Jenkins server, so let's go ahead and install it.

# Install Latest Stable Docker
curl -sSL | sudo sh

# Ensure "jenkins" user can use it without "sudo",
# since we'll be automating jenkins with Docker
sudo usermod -aG docker jenkins

docker ps
docker docker ps

sudo -u jenkins docker ps

# Install Latest Release `docker-compose`
sudo su
curl -L`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

5. Restart Jenkins

We need to restart Jenkins so it picks up the addition of group docker to user jenkins.

sudo service jenkins restart


  • Install Jenkins on RedHat/CentOS:
  • Install Jenkins on Debian/Ubuntu:
  • Install docker-compose:

If you're interested in learning more about Docker and how I use Jenkins with a Docker workflow, check out the 🐳 Shipping Docker series!