Installing Jenkins on Ubuntu

compared with
Current by Matt Smith
on Oct 01, 2015 05:43.

This line was removed.
This word was removed. This word was added.
This line was added.

Changes (12)

View Page History
Recent versions are available in [an apt repository|]. Older but stable LTS versions are in [this apt repository|].

You need to have a JDK and JRE installed. openjdk-6-jre and openjdk-6-jdk installed. openjdk-7-jre and openjdk-7-jdk are suggested. As of 2011-08 gcj is known to be problematic - see [|].

Please make sure to back up any current Hudson or Jenkins files you may have.

wget -q -O - | sudo apt-key add -
sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
* The '{{jenkins}}' user is created to run this service.
* Log file will be placed in {{/var/log/jenkins/jenkins.log}}. Check this file if you are troubleshooting Jenkins.
* {{/etc/default/jenkins}} will capture configuration parameters for the launch like e.g JENKINS_HOME
* By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.

If your {{/etc/init.d/jenkins}} file fails to start jenkins, edit the {{/etc/default/jenkins}} to replace the line
{noformat}HTTP_PORT=8080{noformat} by {noformat}HTTP_PORT=8081{noformat}
Here, 8081 was chosen but you can put another port available.

h1. Deploying on Ubuntu in a cloud (EC2, HP Cloud, OpenStack)

The Ubuntu Jenkins maintainer also maintains the [Juju charm deployment/management script|] for deployment in clouds. It's designed to make it easy to deploy a master with multiple slaves:
juju deploy jenkins
juju deploy -n 5 jenkins-slave
juju add-relation jenkins jenkins-slave

The default password for the 'admin' account will be auto-generated. You can set it using:

juju set jenkins password=mypassword

Always change it this way - this account is used by the charm to manage slave configuration. Then feel free to expose your jenkins master:
juju expose jenkins

h1. Using Linux iptables for port 80 \-> 8080

* This enables port forwarding of traffic between ports 80 and 8080. You can keep Jenkins on the default port 8080 and access it with a normal url without installing anything extra.
* {{sudo nano /etc/rc.local}}
* Then add the following just *before* the exit 0

#Requests from outside
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
#Requests from localhost
iptables -t nat -I OUTPUT -p tcp -d --dport 80 -j REDIRECT --to-ports 8080

Now reboot or run {{sudo /etc/rc.local}} to enable port forwarding. Additional info: []

h1. Setting up an Apache Proxy for port 80 \-> 8080

* {{sudo a2enmod proxy}}
* {{sudo a2enmod proxy_http}}
* {{sudo a2enmod vhost_alias}}

{note}do not do this next command if you already have virtual hosting setup that depends on the default site. See my comment below - danapsimer{note}
* {{sudo a2dissite default}}
* {{Create a file called}} {{{+}jenkins{+}}} {{in}} /etc/apache2/sites-available

{info}If you get {{ERROR: Site default does not exist\!}} then try this instead:
* {{sudo a2dissite 000-default}}

And if all else fails just have a look if there is a default site set up at all:
* {{ls /etc/apache2/sites-enabled/}}
* Create a file called {{jenkins.conf}} in {{/etc/apache2/sites-available}}

<VirtualHost *:80>
ProxyPreserveHost on
ProxyPass / http://localhost:8080/ nocanon
AllowEncodedSlashes NoDecode

* *Install Nginx*.
cd /etc/nginx/sites-available
sudo rm default ../sites-enabled/default
* *Create new configuration for Jenkins*. This example uses {{cat}}, but you can use your favorite text editor. Make sure to replace '' with your domain name.