- Each computer has an user called
jenkinsand a group called
jenkins. 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/jenkinsdirectory is set as the home directory of user
jenkins. Again, this is not a hard requirement, but having the same directory layout makes things easier to maintain.
- All machines run
sshd. Windows agents run
- All machines have
/usr/sbin/ntpdateinstalled, and synchronize clock regularly with the same NTP server.
/var/jenkinshave 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:
/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
/var/jenkins/.sshhas private/public key and
authorized_keysso that a master can execute programs on agents through
ssh, by using public key authentication.
- On master, I have a little shell script that uses rsync to synchronize master's
/var/jenkinsto agents (except
/var/jenkins/workspace). I also use the script to replicate tools on all agents.
/var/jenkins/bin/launch-agentis a shell script that Jenkins uses to execute jobs remotely. This shell script sets up
PATHand a few other things before launching
agent.jar.Below is a very simple example script.
#!/bin/bash JAVA_HOME=/opt/SUN/jdk1.8.0_152 PATH=$PATH:$JAVA_HOME/bin export PATH java -jar /var/jenkins/bin/agent.jar