Installing Jenkins on Ubuntu

compared with
Current by Björn Martin
on Aug 07, 2015 06:37.

Key
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|http://jenkins-ci.org/debian/]. Older but stable LTS versions are in [this apt repository|http://pkg.jenkins-ci.org/debian-stable/].

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 [https://issues.jenkins-ci.org/browse/JENKINS-743|https://issues.jenkins-ci.org/browse/JENKINS-743].

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

{noformat}
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian 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.


{note}
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.
{note}

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

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

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

{noformat}
juju set jenkins password=mypassword
{noformat}

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

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/}}
{info}
* Create a file called {{jenkins.conf}} in {{/etc/apache2/sites-available}}

{code:xml}
<VirtualHost *:80>
</Proxy>
ProxyPreserveHost on
ProxyPass / http://localhost:8080/ nocanon
AllowEncodedSlashes NoDecode
</VirtualHost>
{code}





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