Skip to content

Instantly share code, notes, and snippets.

@amake
Last active June 7, 2016 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amake/4a547440dcc099e91f0cc377c01a9850 to your computer and use it in GitHub Desktop.
Save amake/4a547440dcc099e91f0cc377c01a9850 to your computer and use it in GitHub Desktop.
Jenkins slave connection managed by launchd
<?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>io.jenkins.slave</string>
<key>ProgramArguments</key>
<array>
<!-- If authentication is not required, you can launch via Java Web Start directly in the plist.
Otherwise you need a script like below.
<string>/usr/bin/javaws</string>
<string>-wait</string>
<string>-Xnosplash</string>
<string>$JENKINS_URL/computer/$SLAVE_NAME/slave-agent.jnlp</string>
-->
<string>/path/to/jenkins-slave.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ThrottleInterval</key>
<integer>180</integer>
</dict>
</plist>
#!/bin/sh
JENKINS_URL=http://my.jenkins.instance
JENKINS_TEMP=/tmp/jenkins
mkdir -p $JENKINS_TEMP
cd $JENKINS_TEMP
curl -O $JENKINS_URL/jnlpJars/slave.jar
java -Dfile.encoding=UTF-8 \
-jar slave.jar \
# Use login credentials or slave secret
#-jnlpCredentials $USERNAME:$PASSWORD \
-secret $SLAVE_SECRET \
-jnlpUrl $JENKINS_URL/computer/$SLAVE_NAME/slave-agent.jnlp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment