-
Notifications
You must be signed in to change notification settings - Fork 898
Jenkins Build Agent
Brian Barrett edited this page Oct 31, 2017
·
12 revisions
These instructions are for setting up a new build agent on the community Jenkins server (jenkins.open-mpi.org).
- Have Brian or Howard set up a new Builder in Jenkins. They'll need a node name (usually, the host name), the build root for Jenkins (where you want Jenkins to put all it's stuff), how many builds can occur on the builder at the same time, a general description of the system, and a point-of-contact email address.
- Install the Jenkins agent (below)
- Verify the agent shows as "online" in the Jenkins Build Executor Status on https://jenkins.open-mpi.org/.
Can you add a cron entry as the user you want to use to run Jenkins? If so, these instructions are for you (and assume that your user is someuser
).
- Create a the directory you want to use for Jenkins builds. We'll assume this is
/home/someuser/jenkins/
. - Download https://jenkins.open-mpi.org/jenkins/jnlpJars/agent.jar and copy to
/home/someuser/jenkins/agent.jar
. - Copy the following script to
/home/someuser/jenkins/agent-keepalive.sh
:
#!/bin/bash
JAR_NAME="agent.jar"
AGENT_NAME="MY_AGENT_NAME"
AGENT_SECRET="MY_AGENT_SECRET"
AGENT_WORK_DIR="/home/someuser/jenkins"
JAVA="java"
JCMD="jcmd"
RUN_COMMAND="$JAVA -jar "$JAR_NAME" -jnlpUrl https://jenkins.open-mpi.org/jenkins/computer/$AGENT_NAME/slave-agent.jnlp -secret $AGENT_SECRET -workDir $AGENT_WORK_DIR"
date >> $AGENT_WORK_DIR/agent.out
if ! $JCMD | grep $JAR_NAME > /dev/null ; then
echo "Restarting" >> $AGENT_WORK_DIR/agent.out
cd $AGENT_WORK_DIR
nohup $RUN_COMMAND >>$AGENT_WORK_DIR/agent.out 2>&1 &
fi
- Edit your personal crontab to run
/home/someuser/jenkins/agent-keepalive.sh
every 5-15 minutes (*/5 * * * * /home/someuser/jenkins/agent-keepalive.sh
should do the trick).
- Create a user for the jenkins builder (the rest of these instructions assume it's user
jenkins
with home directory/Users/jenkins
). - Download https://jenkins.open-mpi.org/jenkins/jnlpJars/agent.jar and copy to
/Users/jenkins/agent.jar
. - Copy the following startup script into
/Library/LaunchDaemons/org.open-mpi.jenkins.plist
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.open-mpi.jenkins</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-jar</string>
<string>/Users/jenkins/agent.jar</string>
<string>-jnlpUrl</string>
<string>https://jenkins.open-mpi.org/jenkins/computer/MY_AGENT_NAME/slave-agent.jnlp</string>
<string>-secret</string>
<string>MY_AGENT_SECRET</string>
<string>-workDir</string>
<string>/Users/jenkins</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>UserName</key>
<string>jenkins</string>
</dict>
</plist>
- run
sudo launchctl load /Library/LaunchDaemons/org.open-mpi.jenkins.plist