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.
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
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 binaries, shell scripts, bootstrap 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
Now, we’re gonna good to install 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 -
Now run this
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
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
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
We find that it is in
/usr/share/jenkins. It’s time to go to the corresponding folder and then locate the file.
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.
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
This will open the file browser in Superuser mode.
We copy the
jenkins.war file from
You’ll see a jenkins folder immediately gets created
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
sudo mkdir .jenkins
sudo chown tomcat7:nogroup .jenkins
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
Et Voila! You’ll then see the Jenkins welcome home page