Setting Up Jenkins on Ubuntu Server From Scratch

  Java, Jenkins, Maven, Nexus

Jenkins test run: Webcontainer Apache Tomcat

Now it’s time for our first test run of Jenkins. To make it a bit more challenging, we will write a simple web application which needs to be deployed on a web container. If you already have a web container within your reach, you can skip this page. For all others, we now install Apache Tomcat for our test web application to be deployed to it by a Jenkins job.

Installation of Tomcat8 is very straightforward. Enter the following commands and you are set:

$ sudo apt-get update
$ sudo apt-get install tomcat8

After running the above commands, Tomcat8 should already be up and running as a service.  You can find some vital information about the installation within the last couple of lines of the installation’s screen output:

Setting up libtomcat8-java (8.0.32-1ubuntu1) ...
Setting up tomcat8-common (8.0.32-1ubuntu1) ...
Setting up tomcat8 (8.0.32-1ubuntu1) ...

Creating config file /etc/default/tomcat8 with new version
Adding system user `tomcat8' (UID 112) ...
Adding new user `tomcat8' (UID 112) with group `tomcat8' ...
Not creating home directory `/usr/share/tomcat8'.

Creating config file /etc/logrotate.d/tomcat8 with new version
Setting up authbind (2.1.1+nmu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-3ubuntu1) ...

You can check Tomcat’s status with this command:

$ sudo service tomcat8 status
● tomcat8.service - LSB: Start Tomcat.
 Loaded: loaded (/etc/init.d/tomcat8; bad; vendor preset: enabled)
 Active: active (running) since Tue 2016-04-12 11:32:52 CEST; 30s ago
 Docs: man:systemd-sysv-generator(8)
 CGroup: /system.slice/tomcat8.service
 └─3581 /usr/lib/jvm/java-8-oracle/bin/java -Djava.util.logging.config.file=/var/lib/tomcat8/conf/logging.properties -Djava.util.logging.manager=org.apache.jul...

Tomcat8 is installed under /usr/share/tomcat8 and its configuration files  can be found in /etc/tomcat8.

Now that we have Tomcat installed, we need to setup an admin so we can administer the Tomcat web container. The admin webapp has been separated into a package, so we have to install it first with the following command:

$ sudo apt-get install tomcat8-admin

What’s left to do is creating an admin user by editing the /etc/tomcat8/tomcat-users.xml file so it includes the following lines:

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
<user username="user" password="userpsw" roles="manager-script"/>

Please note that usernames and passwords are just for demonstration purpose. You should definitely use more secure usernames and passwords.

For the user ‘tomcat’ and ‘user’ to become effective, we need to restart Tomcat:

$ sudo service tomcat8 restart

Now you can try opening the Tomcat manager app by requesting the following URL in your browser:

http://ip-of-your-ubuntu-server:8080/manager/html

LEAVE A COMMENT