Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A copy of slave.jar can be downloaded from http://yourserver:port/hudson/jnlpJars/slave.jar

Wiki Markup
\[This gives a 404 error under 1.339 - see [JENKINS-5239|http://issues.jenkins-ci.org/browse/JENKINS-5239]\]
. Many people write scripts in such a way that this 160K jar is downloaded during the script, to make sure the consistent version of slave.jar is always used.

...

This launch mode uses a mechanism very similar to Java Web Start, except that it runs without using GUI, making it convenient for an execution as a daemon on Unix. To do this, configure this slave to be a JNLP slave, take slave.jar as discussed above, and then from the slave, run a command like this:

No Format

$ java -jar slave.jar -jnlpUrl http://yourserver:port/computer/slave-name/slave-agent.jnlp

...

  • Each computer has an user called hudson and 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/hudson directory 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.
  • Master's /var/hudson have all the build tools beneath it --- a few versions of Ant, Maven, and JDKs. JDKs are native programs, so I have JDK copies for all the architectures I need. The directory structure looks like this:
    No Format
    
    /var/hudson
      +- .ssh
      +- bin
      |   +- slave  (more about this below)
      +- workspace (hudson creates this file and store all data files inside)
      +- tools
          +- ant-1.5
          +- ant-1.6
          +- maven-1.0.2
          +- maven-2.0
          +- java-1.4 -> native/java-1.4 (symlink)
          +- java-1.5 -> native/java-1.5 (symlink)
          +- native -> solaris-sparcv9 (symlink; different on each computer)
          +- solaris-sparcv9
          |   +- java-1.4
          |   +- java-1.5
          +- linux-amd64
              +- java-1.4
              +- java-1.5
    
  • Master's /var/hudson/.ssh has private/public key and authorized_keys so 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/hudson to slaves (except /var/hudson/workspace) I use this to replicate tools on all slaves.
  • /var/hudson/bin/launch-slave is a shell script that Hudson uses to execute jobs remotely. This shell script sets up PATH and a few other things before launching slave.jar. Below is a very simple example script.
    Code Block
    
    #!/bin/bash
    
    JAVA_HOME=/opt/SUN/jdk1.6.0_04
    PATH=$PATH:$JAVA_HOME/bin
    export PATH
    java -jar /var/hudson/bin/slave.jar
    

...

  1. Every time Hudson launches a program locally/remotely, it prints out the command line to the log file. So when a remote execution fails, login to the computer that runs the master by using the same user account, and try to run the command from your shell. You tend to solve problems quickly in this way.
  2. Each slave has a log page showing the communication between the master and the slave agent. This log often shows error reports.
  3. If you use binary-unsafe remoting mechanism like telnet to launch a slave, add the -text option to slave.jar so that Hudson avoids sending binary data over the network.
  4. When the same command runs outside Hudson just fine, make sure you are testing it with the same user account as Hudson runs under. In particular, if you run Hudson master on Windows, consult How to get command prompt as the SYSTEM user.
  5. Feel free to send your trouble to users@hudson.dev.java.net

Other readings