Jenkins Mac Slave Communication Setup



Jenkins Slave (Mac) Setup:-
  • Go to Manage Jenkins and Select Manage Nodes

  • Click on New Node
  • Give the node name
  • Give the executors
  • Give the Remote Root Directory
  • Specify a label name, For example: any custom name
  • Select the launch method as: Launch agent via Java Web Start


  • Click on Save, once done with above steps.
  • Below the output, we see once after saving the changes.




To start Mac Slave communication for Jenkins server
  • Create a script for running the java JNLP from slave machine using the below content mentioned in the box.




java -jar /Users/ssp/Downloads/slave.jar -jnlpUrl http://13.126.145.70:8080/computer/MacSlave/slave-agent.jnlp -secret 4c0a0370a9e9a46edfe939ccab0e9f4707715bd663587ab8c9e8e17287c1cf4c -workDir "/Users/ssp/jenkins" 




  • Put the above content in a script (ex: - Mac_Slave_On.sh)
  • Give executable permissions to the script (ex: - chmod +x jenkins_slave.sh)
  • Now To make the script run on boot (Like a startup script)
  • Need to create a <some-name>. plist file under /Library/LaunchAgents/ directory

<?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>Jenkins_Mac_Slave</string>

    <key>OnDemand</key>
    <false/>

    <key>UserName</key>
    <string>jenkins</string>

    <key>ProgramArguments</key>
    <array>
                <string>/bin/bash</string>
              <string>/Users/ssp/jenkins_slave.sh</string>
    </array>
</dict>
</plist>





In the above code, the highlighted line is the script which contains the executable code of JNLP for slave communication with master.
Now, We need to load the above .plist file using launchctl (For startup, Whenever we reboot the mac system, It will automatically launch the code)

  • We need to load the .plist file using the launchctl command with sudo like below

# sudo launchctl load Mac_Slave_On.plist

Once ran the above command, we can reboot the mac once to establish the Master-Slave Jenkins communication
We can also unload the loaded file like below.

# sudo launchctl unload Mac_Slave_On.plist

We can also list the loaded files using the below command

# sudo launchctl list | grep plist








Comments

Popular posts from this blog

GitHub Administration