1

I have Jenkins master running in Windows server 2012.

I have some windows slaves. Connected via JNLP. There is also a Windows Service running in those slaves. So even if I restart windows slaves - they get connected to master once it is up. Awesome!!

I also have a MAC slave. Currently connecting this via Java Web start. I need something like 'Windows Service' for mac. I heard of 'launchd' But it does not seem to connect to master automatically when I restart the MAC machine. This is what I need!!!

I also tried with RunAtLoad as True, KeepAlive as True in the LaunchDaemon. It does not help at all.

4 Answers 4

4

It's built in in The Jenkins JNLP on mac; just install it as a Service :

enter image description here enter image description here

2
  • What!!? Is this from when? I never saw this option..i will try & let you know
    – KitKarson
    Apr 3, 2015 at 15:18
  • 1
    this method no longer works on macos Mojave v10.14.4
    – Andrew Lam
    May 18, 2019 at 3:47
4

Create com.jenkins.slave.plist in /Library/LaunchAgents:

<?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>Label</key>
        <string>com.jenkins.slave</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/bin/java</string>
                <string>-jar</string>
                <string>/Users/jenkins/slave.jar</string>
                <string>-jnlpUrl</string>
                <string>https://YOUR_JENKINS/computer/mac-os-x/slave-agent.jnlp</string>
                <string>-noCertificateCheck</string>
                <string>-secret</string>
                <string>YOUR_SECRET</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
        <key>StandardOutPath</key>
        <string>/Users/jenkins/stdout.log</string>
        <key>StandardErrorPath</key>
        <string>/Users/jenkins/error.log</string>
</dict>
</plist>

Then, update YOUR_JENKINS and YOUR_SECRET credentials, and load service via:

sudo launchctl load /Library/LaunchAgents/com.jenkins.slave.plist

On next login, your slave will automatically connect to the Jenkins Master.

4
  • The -noCertificateCheck argument should not be necessary if your Jenkins installation has SSL.
    – amacleod
    Aug 18, 2020 at 14:46
  • Also remember to change /Users/jenkins to the home directory of your user, if you are using something other than jenkins as the username.
    – amacleod
    Aug 18, 2020 at 14:46
  • hi @amacleod running with latest macos. Setup with all your sugesstion but when load the plist, i got error: Exception in thread "main" java.nio.file.FileSystemException: /": Read-only file system Jan 9, 2021 at 19:16
  • same here. Any ideas how to fix that? Thank you!
    – AndyB
    Feb 11, 2021 at 11:18
1

You could give this a try jenkins-slave-osx

Jenkins Slave for OS X Scripts to create and run a Jenkins slave via Java Web Start (JNLP) on OS X as a Launch Daemon.

Quick Start

bash <( curl -L https://raw.github.com/rhwood/jenkins-slave-osx/master/install.sh )

1
  • 1
    I was really excited after seeing this. But it fails At the step. "Unable to authenticate <user> with this API token". I ensured that i typed correctly.
    – KitKarson
    Oct 17, 2014 at 15:29
0

My only issue was to start the launchDaemon during start up. I did not know how to do it. At last i figured it out by creating an executable to launchDaemon and to invoke the exe from /etc/launchd.conf during start up. It works great now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.