Jenkins- Installation on Ubuntu 14.04 LTS

We talked about the basics and pros of Jenkins in previous post. Now it is time for us to get started and then install Jenkins.

So, first of all, it is important to know that Jenkins is a web based application. To host it in your own system, you need to have a web-server installed-this may be either Tomcat, JBoss, Glassfish etc. My choice has always been Tomcat, so we would first go ahead and install Apache Tomcat on our system.

Installing Tomcat7

As of now, the current stable version of Apache Tomcat is Tomcat7. So without any further ado, we start with installing Tomcat7.

Open your terminal and type the following

$ sudo apt-get install tomcat7

 

Workspace 1_022

 

Workspace 1_023

 

Once you are done with the installation of tomcat7, go to http://localhost:8080/ to make sure that tomcat7 is running properly.

Few things to note : There are few paths that are of specific important –

  • /var/lib/tomcat6 – These are the Java-y files for Tomcat. If you were to just extract Tomcat’s tar file and run it as a local user, these are the files you’d mostly be looking at.
  • /usr/share/tomcat6 – These are the more Linux-y files for Tomcat. Tomcat’s bi­na­ries, shell scripts, boot­strap files, etc.

by default, tomcat7 listens to port no 8080. If you want to change this, you can do this by changing server.xml file in /var/lib/tomcat6/conf.

 

Now, we’re gonna good to install Jenkins.

Installing Jenkins

We need to have the following commands run for installing Jenkins. Before we can install Jenkins, we have to add the key and source list to apt. This is done in 2 steps, first we’ll add the key.

 

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

Workspace 1_024

 

Now run this

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

 

Workspace 1_025

 

We have to then update apt’s cache before we can install Jenkins.

sudo apt-get update

Now install Jenkins with apt

sudo apt-get install jenkins

 

Workspace 1_028

 

Workspace 1_029

 

Workspace 1_030

 

Now that you have Jenkins installed on your system, you are in a good position to run Jenkins, but, after a few modifications. Go to http://localhost:8080/jenkins. You need some more configurations.

Copy the jenkins.war file that you would have recieved after downloading Jenkins. Now you may wander, where is it. Run the whereis command to find where it is

Workspace 1_031

 

We find that it is in /usr/share/jenkins. It’s time to go to the corresponding folder and then locate the file.

Workspace 1_032

Now we need to copy this file to /var/lib/tomcat7/webapps. But there is a catch-
Ubuntu doesn’t allows simply copy pasting of any files or folders in this case, because these are system program files. So you need to have a workaround. We will use the gksudo command to get superuser access and then copy paste the files.

Now gksudo doesn’t comes pre-installed with Linux. So we go ahead and install it too. It is a very light file (~700 KBs).

Once we have it installed, we go ahead and run this command

gksudo nautilus

Workspace 1_033

This will open the file browser in Superuser mode.

Workspace 1_034

We copy the jenkins.war file from /usr/share/jenkins  to  /var/lib/tomcat7/webapps.

You’ll see a jenkins folder immediately gets created

Workspace 1_035

 

If you check http://localhost:8080/jenkins now, you’ll get your still get an error:

Unable to create the home directory '/usr/share/tomcat6/.jenkins'. This is most likely a permission problem.

To change the home directory, use JENKINS_HOME environment variable or set the JENKINS_HOME system property. See Container-specific documentation for more details of how to do this.


Now you will need to run these three commands

cd /usr/share/tomcat7

sudo mkdir .jenkins

sudo chown tomcat7:nogroup .jenkins

Workspace 1_037

 

Now go ahead and re-start your tomcat7 server with this command

sudo service tomcat7 restart

Once tomcat7 restarts, go ahead and type this in browser http://localhost:8080/jenkins. You will see Jenkins start up. It will take some time at first

Workspace 1_038
Et Voila! You’ll then see the Jenkins welcome home page

Workspace 1_039

 

7 thoughts on “Jenkins- Installation on Ubuntu 14.04 LTS

    1. You can provide the port number at run time using `java -jar jenkins.war –httpPort=9090` if you want jenkins to start at port 9090. If you want to change the configuration to have the port started at different port than 8080 everytime, then you need to change the configuration file.

      Use this link as a reference to see how to do that.

      Like

  1. HTTP Status 404 – /manager/html

    type Status report

    message /manager/html

    description The requested resource is not available.
    Apache Tomcat/7.0.52 (Ubuntu)

    i have changed the user name and password in the manager webapp and the host-manager webapp.

    i have edited the user xml but stile i am getting the error

    <!–

    –>

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.