...
- Each computer has an user called
jenkins
and a group calledjenkins
. All computers use the same UID and GID. (If you have access to NIS, this can be done more easily.) This is not a Jenkins requirement, but it makes the agent management easier. - On each computer,
/var/jenkins
directory is set as the home directory of userjenkins
. Again, this is not a hard requirement, but having the same directory layout makes things easier to maintain. - All machines run
sshd
. Windows agents runcygwin sshd
. - All machines have
/usr/sbin/ntpdate
installed, and synchronize clock regularly with the same NTP server. Master's
/var/jenkins
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/jenkins +- .ssh +- bin | +- agent (more about this below) +- workspace (jenkins 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) +- java-1.8 -> native/java-1.8 (symlink) +- native -> solaris-sparcv9 (symlink; different on each computer) +- solaris-sparcv9 | +- java-1.4 | +- java-1.5 | +- java-1.8 +- linux-amd64 +- java-1.4 +- java-1.5 +- java-1.8
- Master's
/var/jenkins/.ssh
has private/public key andauthorized_keys
so that a master can execute programs on agents throughssh
, by using public key authentication. - On master, I have a little shell script that uses rsync to synchronize master's
/var/jenkins
to agents (except/var/jenkins/workspace
). I also use the script to replicate tools on all agents. /var/jenkins/bin/launch-agent
is a shell script that Jenkins uses to execute jobs remotely. This shell script sets upPATH
and a few other things before launchingagent.jar.
Below is a very simple example script.Code Block #!/bin/bash JAVA_HOME=/opt/SUN/jdk1.8.0_152 PATH=$PATH:$JAVA_HOME/bin export PATH java -jar /var/jenkins/bin/agent.jar
...