One way of doing this is to configure a master to launch a slave agent on the target machine. On Unix, this can be done by SSH, RSH, or other similar means. On Windows, this could be done by the same protocols through cygwin or tools like psexec.
The slave agent program is a simple Java program that can be launched like
java -jar slave.jar. A copy of
slave.jar can be found inside
WEB-INF. Therefore, a typical slave agent launch command would look something like
ssh myslave java -jar ~/bin/slave.jar.
- Each computer has an user called
hudsonand a group called
hudson. All computers use the same UID and GID. (If you have access to NIS, this can be done more easily.) This is not a Hudson requirement, but it makes the slave management easier.
- On each computer,
/var/hudsondirectory is set as the home directory of user
hudson. Again, this is not a hard requirement, but having the same directory layout makes things easier to maintain.
- All machines run SSHD. Windows slaves run cygwin sshd.
- All machines have ntp client installed, and synchronize clock regularly with the same NTP server.
/var/hudsonhave all the build tools beneath it --- a few versions of Ant, Maven, and JDKs. JDKs are native programs, so I have JDK copys for all the architectures I need. The directory structure looks like this:
bin | +- slave (more about this below)
+- workspace (hudson creates this file and store all data files inside)
tools +- ant-1.5
+- java-1.4 -> native/java-1.4 (symlink)
+- java-1.5 -> native/java-1.5 (symlink)
+- native -> solaris-sparcv9 (symlink; different on each computer)
| +- java-1.4
| +- java-1.5
/var/hudson/.sshhas private/public key and
authorized_keysso that a master can execute programs on slaves through ssh, by using public key authentication.
- On master, I have a little shell script that uses rsync to synchronize master's
/var/hudsonto slaves (except
/var/hudson/workspace) I use this to replicate tools on all slaves.
/var/hudson/bin/launch-slaveis a shell script that Hudson uses to execute jobs remotely. This shell script sets up
PATHand a few other things before launching
- Finally all computers have other standard build tools like
cvsinstalled and available in PATH.