Friday, January 11, 2013

more headless jenkins under Mac OS X 10.x

Steps to create a headless Slave Jenkins Mac OS X

1. Install Java VM or JDK
    Downloading .DMG from Oracle Java site. Install
2. Install Apple X Code development plus command line package
    Download from Apple Developers site
3. Connect under-setup Jenkins Mac Slave to Jenkins Master through web browser
4. Create a Mac Slave Node on Master
5. From Slave, connect to Master from Mac Slave Node using command line:
    javaws http://<your jenkins master>:8080/computer/<YOUR SLAVE MACHINE NAME>/slave-agent.jnlp
or if the slave is headless:
    java -jar slave.jar -jnlpUrl http://<your jenkins master>:8080/computer/<YOUR SLAVE MACHINE NAME>/slave-agent.jnlp

6. The above step #5 will fail as expected

7. Create a .plist file org.jenkins-ci.plist for launchDaemons in
    /Library/LaunchDaemons/<create a dir name here>
All paths here are specific for my system.
---

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>StandardOutPath</key>
    <string>/Users/Shared/build-slave/jenkins.log</string>
    <key>StandardErrorPath</key>
    <string>/Users/Shared/build-slave/jenkins.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>JENKINS_HOME</key>
<string>/Users/Shared/build-slave</string>
</dict>
<key>GroupName</key>
<string>daemon</string>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.jenkins-ci</string>
<key>ProgramArguments</key>
<array>
                <string>/bin/bash</string>
<string>/Library/Application Support/build-slave/start-headless-jenkins-slave.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>your user</string>
        <key>SessionCreate</key>
<true />
</dict>
</plist>
---


8. Create a LaunchDaemon script start-headless-jenkins-slave.sh in
    /Library/Application Support/<create a dir name here>
----
#!/bin/bash
/usr/bin/java -jar slave.jar -jnlpUrl http://<your jenkins master:8080>/computer/<your mac slave>/slave-agent.jnlp
----

9. Create a launchDaemon script to start jenkins headless slave in case you want to do it manually, test, etc.
sudo launchctl load -w /Library/LaunchDaemons/org.jenkins-ci.plist

10. Put the command line in /etc/launchd.conf to start everytime the system reboots
...
launchctl load -w /Library/LaunchDaemons/org.jenkins-ci.plist
...

------
some examples of launchctl:

sudo launchctl list
sudo launchctl unload -w /System/Library/LaunchDaemons/finger.plist
sudo launchctl load -w /System/Library/LaunchDaemons/finger.plist
...

http://ss64.com/osx/launchctl.html
http://www.dowdandassociates.com/content/howto-set-environment-variable-mac-os-x-etclaunchdconf

No comments:

Post a Comment