Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning
titleOut of date

Consider this content out of date, please see jenkins.io/download and the linked pages for installation instructions

 

 

 

On Debian-based distributions, such as Ubuntu, you can install Jenkins through apt-get.

...

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

Installation

No Format

wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

...

Once installed like this, you can update to the later version of Jenkins (when it comes out) by running the following commands:

No Format

sudo apt-get update
sudo apt-get install jenkins

...

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:

No Format

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:

No Format

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:

No Format

juju expose jenkins

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
No Format

#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 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080

...

  • Create a file called jenkins.conf in /etc/apache2/sites-available
Code Block
xml
xml

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	ServerName ci.company.com
	ServerAlias ci
	ProxyRequests Off
	<Proxy *>
		Order deny,allow
		Allow from all
	</Proxy>
	ProxyPreserveHost on
	ProxyPass / http://localhost:8080/ nocanon
	AllowEncodedSlashes NoDecode
</VirtualHost>

...

This configuration will setup Nginx to proxy port 80 to 8080 so that you can keep Jenkins on 8080. Instructions originally found in a GitHub Gist from rdegges: https://gist.github.com/913102

  • Install Nginx.

    Code Block
    
    sudo aptitude -y install nginx
    
  • Remove default configuration.

    Code Block
    
    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 'ci.yourcompany.com' with your domain name.
    Note: Sometimes your permissions (umask, etc) might be setup such that this won't work. Create the file somewhere else then copy it into place if you run into that problem.

    Code Block
    
    sudo cat > jenkins
    upstream app_server {
        server 127.0.0.1:8080 fail_timeout=0;
    }
    
    server {
        listen 80;
        listen [::]:80 default ipv6only=on;
        server_name ci.yourcompany.com;
    
        location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
    
            if (!-f $request_filename) {
                proxy_pass http://app_server;
                break;
            }
        }
    }
    ^D # Hit CTRL + D to finish writing the file
    
  • Link your configuration from sites-available to sites-enabled:

    Code Block
    
    sudo ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
    
  • Restart Nginx

    Code Block
    
    sudo service nginx restart
    

...