Install and configure Jenkins on Ubuntu 16.04

Jenkins on Ubuntu 16.04

Introduction

Jenkins is an automation server written in Java, as a fork of the Hudson project. It helps to automate part of the software development process, with aids like continuous integration, but also by further empowering teams to implement the technical part of a Continuous Delivery. Jenkins supports many SCM (Source Control Management) software systems including Git, SVN, and Mercurial and provides hundreds of plugins to automate projects.
This tutorial explains how to install and use Jenkins on Ubuntu 16.04 using Apache as server.

Install Java

Jenkins requires Java, so, install OpenJDK7 on the server. First, install python-software-properties:

# apt install python-software-properties

Then you can add Java repository:

# add-apt-repository ppa:openjdk-r/ppa

Update Ubuntu repos and install OpenJDK:

# apt update
# apt install openjdk-7-jdk

Run $ java -version to verify that you have OpenJDK7 correctly installed.

Install Jenkins

Jenkins team provides a repository for Ubuntu. First, add it:

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

Update repository and install Jenkins:

# apt update
# apt install jenkins

The installation process will perform the following tasks:

  • Setup Jenkins as a daemon launched on start
  • Create a Jenkins user to run this service
  • Direct console log output to the file /var/log/jenkins/jenkins.log
  • Populate /etc/default/jenkins with configuration parameters for the launch
  • Set Jenkins to listen on port 8080. Access this port with your browser to start configuration

Next, start Jenkins:

# systemctl start jenkins

Verify that it is running and listening on port 8080 with the following command:

# nestat -plntu | grep 8080

You will see a line like this:

tcp6       0      0 :::8080                 :::*                    LISTEN      122        54406       12370/java

Install and Configure Apache

Install Apache web server on your system:

# apt install apache2

Next, enable the proxy and proxy_http modules for configuring it as a front end server and reverse proxy for Jenkins. This is done by executing the following commands:

# a2enmod proxy
# a2enmod proxy_http

Now you must create a new Virtual Host file in the /etc/apache2/sites-available/ directory.

# $EDITOR /etc/apache2/sites-available/jenkins.conf

Here, paste the following lines:

<Virtualhost *:80>
    ServerName        my.jenkins.id
    ProxyRequests     Off
    ProxyPreserveHost On
    AllowEncodedSlashes NoDecode
 
    <Proxy http://localhost:8080/*>
      Order deny,allow
      Allow from all
    </Proxy>
 
    ProxyPass         /  http://localhost:8080/ nocanon
    ProxyPassReverse  /  http://localhost:8080/
    ProxyPassReverse  /  http://my.jenkins.id/
</Virtualhost>

Save the file and activate the Jenkins Virtual Host with the a2ensite command.

# a2ensite jenkins

All these modifications will become effective after restarting Apache and Jenkins, so:

# systemctl restart apache2
# systemctl restart jenkins

Executing the following command, you can verify that Apache is using port 80 and Jenkins port 8080:

netstat -plntu | grep 80

Configure Jenkins

Open your browser, and go to URL http://localhost:8080
You will see this page:
1
On your terminal, execute the following command:

# cat /var/lib/jenkins/secrets/initialAdminPassword

Copy the prompted password; in my case, this is: f698b591187c40f298f24eea4847734a
Paste it on Jenkins configuration page, and click Continue
2
Click on Install suggested plugins. It will install various plugins automatically. This process will not take too long.
Next, we must create a new admin user:
3
Enter the required information, and then click on Save and finish. In the next page, click on Start using Jenkins and it will open the Jenkins Dashboard.

Configure security

Now that installation is finished, we need to configure Jenkins standard security settings.
On the Dashboard, click on Manage Jenkins -> Configure Global Security. You will see a page with different settings. Scroll and enable Matrix-based security. This will let you chose permissions for users. Add the user “admin”, and give him all permissions. To Anonymous, enable just the Read. Click on Save.

From now on, you can use your Jenkins based server for managing development jobs. Through the Dashboard you can add users, create new projects and configure them.

  • [email protected]

    I’ve profited 104,000 bucks previous year by working online from my house a­n­d I did it by w­orking part-time f­­o­­r 3 or sometimes more hours daily. I’m using an earning opportunity I stumbled upon from this website i found online and I am so happy that i earned so much extra income. It’s so beginner-friendly a­n­d I am just so grateful that i discovered this. This is what i do… STATICTAB.COM/x4biwaa

  • I’ve profited 104 thousand bucks in last 12 months by working online from home a­n­d I did it by work­ing part-time f­o­r 3+ hrs each day. I’m using a business opportunity I stumbled upon from company that i found online and I am amazed that i earned such great money. It’s so beginner friendly a­­n­­d I’m so grateful that i found it. Here’s what I do… STATICTAB.COM/x4biwaa

  • I got paid $104,000 in last 12 months by doing an online job at home a­­n­­d I was able to do it by wo­rking in my own time for 3 or sometimes more h each day. I used a money making model I was introduced by this website i found online and I am so thrilled that i made so much money. It’s really newbie friendly and I am just so grateful that i found it. Check out what I do… STATICTAB.COM/gpfvgtj

  • tucker-claire

    I’ve earned $104k last year by freelancing on-line a­­n­­d I was able to do it by w­o­r­k­i­n­g part-time for few hours daily. I used an earning opportunity I stumbled upon online and I am so happy that i earned so much extra income. It’s newbie friendly a­n­d I’m just so blessed that I found out about this. Here is what i do… STATICTAB.COM/owgxpdb

  • I’ve profited $104000 last year by freelancing online and I manage to accomplish that by w­o­r­k­i­n­g part time f­­o­­r few h each day. I was following work model I found on-line and I am excited that i was able to make so much money. It’s very user-friendly a­n­d I am just so blessed that i discovered it. This is what i did… STATICTAB.COM/r2tyhgi

  • [email protected]

    I profited 104,000 thousand dollars last year by doing an online job a­­n­­d I manage to do it by working part time f­o­r few hours /day. I was following an earning model I was introduced by this website i found on-line and I am so happy that i made so much money. It’s beginner-friendly a­­n­­d I am just so thankful that i found this. This is what i did… STATICTAB.COM/astkxim

  • I got paid 104,000 bucks in last twelve months by working on-line a­­n­­d I manage to do it by working in my own time f­­o­­r several h on daily basis. I used work opportunity I came across from this website i found online and I am thrilled that i earned such great money. It’s so user friendly and I am just so blessed that i discovered it. Check out what I do… STATICTAB.COM/iyxniid

  • [email protected]

    I was paid 104,000 bucks in last 12 months by doing an on-line job a­­n­­d I was able to do it by w­orking part time f­o­r 3 or sometimes more hours /day. I followed an earning model I came across online and I am so amazed that i made so much money on the side. It’s user friendly a­n­d I’m just so grateful that I found out about it. Here’s what I do… STATICTAB.COM/iyxniid

  • I profited 104,000 thousand dollars in 2016 by freelancing from home a­­n­­d I was able to do it by w­orking in my own time for 3 or sometimes more hours a day. I’m using an earning model I was introduced by this company i found on-line and I am so amazed that I was able to earn so much money. It’s so newbie-friendly and I’m so happy that i learned about it. Here’s what I did… please visit my account for webpage

  • I’ve profited 104 thousand bucks in last twelve months by doing an online job a­­n­­d I was able to do it by wor­king part-time f­o­r several hrs every day. I’m using work model I came across from company that i found online and I am happy that I was able to earn so much extra income. It’s user friendly a­­n­­d I’m so thankful that i learned about it. Here’s what I did…TWITTER.COM/StinnettMargar1/status/835739136078163968

  • I’ve profited 104 thousand bucks last year by working from my house a­­n­­d I did it by w­o­r­k­i­n­g in my own time f­­o­­r few hours daily. I followed an earning opportunity I came across online and I am so happy that I was able to earn so much money on the side. It’s really beginner friendly a­n­d I’m just so grateful that I found out about it. Here’s what I did… EASYURL.NET/f2265

  • I was without work for six months when my former Co-worker at last advised me to begin with freelancing online… That was only just after I received $5000 in my initial thirty days when I seriously believed I really could do this for a living! Today I am happier than ever… I work from home as well as I am my own boss now like I always wanted… I see a number of not satisfied people around me, working the same old boring job that’s sucking the everyday life from all of them day-after-day… Each time I see some-one similar to that I say START FREELANCING MAN! This is where I started out >>>> http://libr­.­ae/o9tz