Skip to content

Instantly share code, notes, and snippets.

@rodreegez
Created May 6, 2010 15:24
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rodreegez/392258 to your computer and use it in GitHub Desktop.
Save rodreegez/392258 to your computer and use it in GitHub Desktop.
Hudson, Ruby Enterprise Edition, Nginx.

Testing Rails with Hudson CI

Written for Ubuntu LTS 10.4

Update and upgrade

  $ sudo aptitude update
  $ sudo aptitude upgrade

Install build-essential and friends

  $ sudo aptitude install build-essential zlib1g-dev libssl-dev libreadline5-dev openssh-server git-core

Add Hudson package repo to sources.

Add the key:

  $ wget -O - http://hudson-ci.org/debian/hudson-ci.org.key | sudo apt-key add -

Add the repository to apt:

  $ sudo add-apt-repository 'deb http://hudson-ci.org/debian binary/'

Update apt and install Hudson:

  $ sudo aptitude update
  $ sudo aptitude install hudson

Install Nginx

sudo aptitude install nginx

Configure Nginx

Make Hudson available at a URL:

  $ sudo vim /usr/local/nginx/conf/nginx.conf

Then add this to the end of the file (but before the last '}'):

  # Hudson
  upstream hudson {
      server 127.0.0.1:8080;
  }

  server {
      server_name  ci.your-url.com; # replace this with the URL you want
                                    # Hudson to be available at
      root /var/lib/hudson;

      location / {
          proxy_pass http://hudson/;
          auth_basic "Hudson CI";
          auth_basic_user_file /var/opt/hudson/htpasswd;
     }

  }

Create a username and password (first you need apache2-utils):

  $ sudo apt-get install apache2-utils
  $ sudo mkdir -p /var/opt/hudson
  $ cd /var/opt/hudson
  $ sudo htpasswd -b -c htpasswd *username* *password*

Now visit http://ci.your-url.com and check you can log in with the username and password you set. You should see your Hudson instance running.

Configure Git & Github

Generate an ssh key-pair for the hudson user (create it in the default location and don't set a password):

  $ sudo su hudson
  $ ssh-keygen -t rsa -C "you@your-domain.com"

Configure Git:

  $ git config --global user.email "you@example.com"
  $ git config --global user.name "Your Name"

Copy your ssh public key:

  $ su *your normal user*
  $ sudo apt-get install xclip
  $ sudo cat /var/lib/hudson/.ssh/id_rsa.pub | xclip -sel clip

And add it to your GitHub account.

Next, ssh to GitHub to authenticate:

  $ sudo su hudson
  $ ssh git@github.com

Configure Hudson

  • Visit http://ci.your-url.com
  • Follow to Manage Hudson > Manage Plugins and install any plugins you need (like Git).
  • Add a new project to test the system (something like FauxPass).
  • Add SCM details and build script.
  • Click Build Now.

Make Nginx allow GitHub to trigger builds in Hudson

(if you are currently the hudson user, switch back to your regular user now)

Open the nginx conf:

  $ sudo vim /etc/nginx/conf/nginx.conf

Add a second location with auth_basic turned off:

  location ~ /job/(.*)/build {
      auth_basic off;
      proxy_pass http://hudson;
  }

Then visit https://github.com/Username/project-name/edit?hooks=1 and add http://ci.your-url.com/job/*projectname*/build as a post-recive url.

Mysql

  $ sudo aptitude install mysql-server mysql-client libmysql-ruby libmysqlclient-dev
  $ sudo gem install mysql

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment