How to Install Jenkins in Ubuntu
Tags: ci, testing, devops
Published: 2017-11-28 10:39:23

---
title: How to Install Jenkins in Ubuntu
published: true
description: After introducing you to Jenkins in our first post, now we'll run through how to get it installed and setup in Ubuntu.
tags: ci, testing, devops
canonical_url: https://bugfender.com/blog/how-to-install-jenkins-in-ubuntu/
---

![](https://bugfender.com/wp-content/uploads/2017/11/bugfender-installing-jenkins.jpg)

*This article was originally posted on our [blog](https://bugfender.com/blog/how-to-install-jenkins-in-ubuntu/).*

Incase you missed our first post, or if you aren't sure just what Jenkins or CI is, head back and read: <a href="https://bugfender.com/blog/what-is-jenkins-and-why-should-you-be-using-it/">What Is Jenkins and Why Should You Be Using It?</a>

If you’re getting started with Jenkins, there are many things to consider before you hit download. You have to choose where to run Jenkins: on hardware that you maintain yourself or through a hosting service. You should work with your team to decide on the best option for your needs.

As a <a href="https://bugfender.com" target="_blank">fully remote lifestyle business</a>, we chose to use Amazon Web Services on a t2.nano machine type with Ubuntu 16.04, but this configuration can be adapted depending on the use case.

<h2>Selecting the Right Machine</h2>

Make sure you choose a machine with at least 1GB of RAM. If you don’t have enough internal memory, Jenkins won’t run. For decent performance, 2 to 4GB is ideal.

For Android, we would recommend a t2.medium machine at least. For iOS, you need a Mac, so we would recommend a Mac Mini. Many people find an older Macbook around the office and use it to run Jenkins.

<h2>Choosing an Operating System</h2>

Jenkins runs on nearly any operating system you can imagine, as long as it can run Java or Docker. For this post I will be using Ubuntu, but you can use whatever operating system suits you best because the steps are very similar.

<h2>How to Install Jenkins</h2>

<h3>Step 1: Install Jenkins using your package manager.</h3>

On Ubuntu you can do this with:

<pre class="no-wrap">wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
echo "deb http://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list
sudo apt-get update && sudo apt-get -y install jenkins</pre>

Note: You have other installation options including two different release lines. See <a href="https://jenkins.io/download/" rel="noopener" target="_blank">https://jenkins.io/download/</a> to learn the difference between weekly release and LTS (long-term support) options.

Once installed, Jenkins will be running on port 8080. If you are accessing this server remotely, make sure to open the port 8080 in your firewall. 

<h3>Step 3: Open Your Browser</h3>

In your browser, go to <code>http://your-ci-server-name.com:8080</code>. If your machine is running Jenkins, the window should display the setup wizard.

<h3>Step 4: Unlocking Jenkins</h3>

<img src="https://bugfender.com/wp-content/uploads/2017/11/jenkins-2-2-unlock.png" alt="" width="1200" height="819" class="aligncenter size-full wp-image-4596" />

In order to ensure that you’re the real administrator of the machine, the password has been written to a specified log file. In a fresh terminal, type in <code>sudo cat</code> and then paste in the pathway provided on this page in order to get a temporary password. Then you can enter the password in the <strong>Administrator password</strong> field in your browser. This step is a security measure in case your Jenkins download is publicly accessible from the internet or your company’s network. (For information about more security measures for Jenkins, see “Recommended detour: add SSL to protect your Jenkins installation” below.)

<h3>Step 5: Customizing Jenkins Plugins</h3>

<img src="https://bugfender.com/wp-content/uploads/2017/11/jenkins-2-3-customize.png" alt="" width="1200" height="819" class="aligncenter size-full wp-image-4597" />

You can go ahead and click the <strong>Install the suggested plugins box</strong>. This will activate the download of a handful of useful plugins, including Git and some Pipeline plugins. You can always <a href="https://plugins.jenkins.io" rel="noopener" target="_blank">download other plugins</a> as necessary to supplement these pre-selected options.

<h3>Step 6: Create Admin Login</h3>

<img src="https://bugfender.com/wp-content/uploads/2017/11/jenkins-2-4-admin-user.png" alt="" width="1200" height="819" class="aligncenter size-full wp-image-4598" />

You can create your user account by adding a username, entering a new password, and including a full name and email address. Once you’re in Jenkins, you can choose to enable new users which will allow colleagues to create additional logins as needed.

And that’s it! You’ve installed Jenkins.

<img src="https://bugfender.com/wp-content/uploads/2017/11/jenkins-2-5-ready.png" alt="" width="1200" height="819" class="aligncenter size-full wp-image-4599" />

<h2>Recommended Detour: Add SSL to Protect Your Jenkins Installation</h2>

Since Jenkins has access to your application’s source code, we recommend you use encryption. The essence of your product--the code--is likely sensitive and should be kept private. If you are running Jenkins through the internet or on a local network shared with other people, it might be good to protect communications with SSL.

Since the launch of <a href="https://letsencrypt.org/" rel="noopener" target="_blank">Let’s Encrypt</a>, it’s fairly easy and completely free to get these certificates, so we highly recommend it. Don’t be lazy!

<strong>Step 1:</strong> If your server is behind a firewall, first make sure you are accepting inbound traffic on ports 80 and 443, and remove access to port 8080.

In order to get SSL working, you’ll first need a DNS name for your server. In this example, we are calling it <code>your-ci-server-name.com</code>. Make sure to edit the configuration files we will be listing here to match the domain name you choose.

<strong>Step 2:</strong> Then install nginx (<code>sudo apt-get install nginx</code>) and edit your <code>/etc/nginx/sites-enabled/default</code> file to look like this:

<pre class="no-wrap">upstream app_server {
    server 127.0.0.1:8080 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    location ^~ /.well-known/acme-challenge/ {
        alias /usr/share/nginx/html/.well-known/acme-challenge/;
    }
    location / {
        return 301 https://$host$request_uri;
    }
}</pre>

Once it is installed, ask nginx to load your changes: <code>service nginx reload</code>

This will let the Let’s Encrypt validation service talk to your server and verify that you own it.

<strong>Step 3:</strong> Now you can install the Let’s Encrypt agent and make an SSL certificate for your server:

<pre class="no-wrap">sudo apt-get install letsencrypt
letsencrypt</pre>

Follow the steps of the wizard and you will end up with your SSL certificates in a directory like <code>/etc/letsencrypt/live/your-ci-server-name.com/</code>.

Now edit again <code>/etc/nginx/sites-enabled/default</code> to use those certificates, add the following lines:

<pre class="no-wrap">server {
    listen       443;
    server_name  <code>your-ci-server-name.com</code>;
    ssl    on;
    ssl_certificate    /etc/letsencrypt/live/<code>your-ci-server-name.com</code>/fullchain.pem;
    ssl_certificate_key    /etc/letsencrypt/live/<code>your-ci-server-name.com</code>/privkey.pem;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        if (!-f $request_filename) {
            proxy_pass http://app_server;
            break;
        }
    }
}</pre>

Then again ask nginx to load your changes: <code>service nginx reload</code>

<strong>Step 4:</strong> Now you should have SSL, try opening <code>https://your-ci-server-name.com</code> on your browser. If you followed these steps correctly you will looking at your brand new encrypted Jenkins installation.

Now that Jenkins is fully installed, keep an eye out for our upcoming posts on adding your first Android and iOS jobs.

<hr style="margin: 40px 0;">

<p class="text-p">This post was edited by Sarabeth Flowers Lewis, a freelance writer and co-founder of Lewis Commercial Writing, specializing in SEO and direct response content creation. She currently works remotely with her ginger husband writing for tech, nonprofits, and real estate. See more of her work <a href="https://www.lewiscommercialwriting.com/" rel="noopener" target="_blank">here</a>.</p>

*This article was originally posted on our [blog](https://bugfender.com/blog/how-to-install-jenkins-in-ubuntu/).*