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
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 /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 -
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.
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
This will open the file browser in Superuser mode.
We copy the jenkins.war
file from /usr/share/jenkins
to /var/lib/tomcat7/webapps
.
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
cd /usr/share/tomcat7
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
Can you give a good tutorial for ho to Restore backup in another jenkins server ?
LikeLike
how can i run tomcat and jenkins in different ports
LikeLike
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.
LikeLike
thanks for the solution i wandet to change the port to Archive the war file
i changed it in server xml it’s working
LikeLike
To Archive the war file
LikeLike
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
<!–
–>
LikeLike
Hey, I’m not clear about what error you’re facing. Can you explain this again.
LikeLike
This is a great article, Thanks for sharing this.
If you have ever encountered an issue with not connecting the Jenkins server from a remote PC, the below article might help you.
https://techiewheel.blogspot.com/2022/02/why-i-cannot-access-jenkins-server-from.html
LikeLike