Installing Jenkins on tomcat 8

Posted on Saturday, January 25, 2014


This guide will go over installing and setting up Jenkins on an fresh Ubuntu 12.04 server.

Installing Java 7


Install the latest java 7 files


>  sudo apt-get purge openjdk*
>  sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
>  sudo apt-get update
>  sudo apt-get install oracle-java7-installer
>  java -version






Installing Tomcat 8.0


Download Tomcat to the local directory

The Tomcat 8.0 download page can be found at

(this link may change over time)

>  wget http://mirror.reverse.net/pub/apache/tomcat/tomcat-8/v8.0.0-RC10/bin/apache-tomcat-8.0.0-RC10.tar.gz


Extract the file


>  tar xvzf apache-tomcat-8.0.0-RC10.tar.gz


Move the tomcat over


>  sudo mv apache-tomcat-8.0.0-RC10 /opt/tomcat



Now set up the tomcat users.


> sudo vi /opt/tomcat/conf/tomcat-users.xml



Add the following lines within the <tomcat-users> element  (put your own password)


  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <user name="admin"   password="mypassword"
                              roles="admin-gui, manager-gui,
                              manager-script, admin-script" />
  



Fix the connector, This has some issue with Jenkins if not fixed.


> sudo vi +68 /opt/tomcat/conf/server.xml


And add this to the connector
URIEncoding="UTF-8"



Set up start up script


> sudo vi /etc/init.d/tomcat


Then place the following in it.


# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid


export JAVA_HOME=/usr/lib/jvm/java-7-oracle
export JENKINS_HOME=/opt/jenkins


case $1 in
start)
sh /opt/tomcat/bin/startup.sh
;;
stop)
sh /opt/tomcat/bin/shutdown.sh
;;
restart)
sh /opt/tomcat/bin/shutdown.sh
sh /opt/tomcat/bin/startup.sh
;;
esac
exit 0


Make it executable


> sudo chmod 755 /etc/init.d/tomcat



Add it to autostart


> sudo update-rc.d tomcat defaults


Reboot to test auto start of tomcat


> sudo reboot now


Open







Install Jenkins

Download Jenkins 1.548 from http://jenkins-ci.org/ [2]


> wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war


Go to the tomcat manager to install the war file


For Context path enter /jenkins
For the war location enter /home/patman/jenkins.war
And click deploy



Now Jenkins is installed


Open Jenkins





Check to make sure the jenkins home directory is correct.
Click on Manage Jenkins



Then configure system



Home directory should be /opt/jenkins





Set up Jenkins security


Now that Jenkins is set up we need to set up its security to prevent unwanted users from logging in an running builds.  Out of the box anyone can get into Jenkins which is a bit of a security risk.

From the main Jenkins screen click on “Manage Jenkins”




Then click on Configure Global Security



Checkbox Enable Security



We are going to use our unix users /groups.  
Checkbox “Unix user/group database”  then click test to test the connection.  If it returns success you are good.




After clicking Test you should see "Success"




Select the Matrix-based Security and add each user individually



Add users or groups by hand



Then give them every permission (but make sure anonymous has no permissions).




Click Save at the bottom.




Now if you go to jenkins you will get a login prompt.







Put in your username/password  and login



That is it for a basic Jenkins install I have not set up any builds yet in it or set up Ant.


I will cover those in other articles.



References
[1]        Tomcat 8.0 download page
                Accessed 01/2014
[2]        Jenkins hompage
            http://jenkins-ci.org/
                Accessed 01/2014



No comments:

Post a Comment