1This are the steps to be done for configuring a mac for being a build slave to the Kodi jenkins CI system
2--------------------------------------------------------------------------------------------------------
3
41. setup user jenkins as follows:
5
6# create jenkins group
7NEXT_GID=$((`dscl /Local/Default list /Groups gid | awk '{ print $2 }' | sort -n | grep -v '^[5-9]' | tail -n1` + 1))
8sudo dscl /Local/Default create /Groups/jenkins
9sudo dscl /Local/Default create /Groups/jenkins PrimaryGroupID $NEXT_GID
10sudo dscl /Local/Default create /Groups/jenkins Password \*
11sudo dscl /Local/Default create /Groups/jenkins RealName 'Jenkins Node Service'
12# create jenkins user
13NEXT_UID=$((`dscl /Local/Default list /Users uid | awk '{ print $2 }' | sort -n | grep -v '^[5-9]' | tail -n1` + 1))
14sudo dscl /Local/Default create /Users/jenkins
15sudo dscl /Local/Default create /Users/jenkins UniqueID $NEXT_UID
16sudo dscl /Local/Default create /Users/jenkins PrimaryGroupID $NEXT_GID
17sudo dscl /Local/Default create /Users/jenkins UserShell /usr/bin/false
18sudo dscl /Local/Default create /Users/jenkins NFSHomeDirectory /var/lib/jenkins
19sudo dscl /Local/Default create /Users/jenkins Password \*
20sudo dseditgroup -o edit -a jenkins -t user jenkins
21# create the jenkins home dir
22sudo mkdir /var/lib/jenkins
23sudo chown -R jenkins:wheel /var/lib/jenkins
24# create a logging space
25sudo mkdir /var/log/jenkins
26sudo chown jenkins:wheel /var/log/jenkins
27
283. mkdir /Users/Shared/jenkins
29
304. sudo chown jenkins:wheel /Users/Shared/jenkins
31
325. mkdir -p /Users/Shared/xbmc-depends/dSyms
33
346. sudo chown -R jenkins:wheel /Users/Shared/xbmc-depends/
35
367. Change to user jenknis via sudo -u jenkins bash
37
388. mkdir /Users/Shared/jenkins/slave
39
409. nano /Users/Shared/jenkins/slave/startslave.sh and add the following
41
42#!/bin/sh
43
44rm error.log
45rm stdout.log
46java -Djava.awt.headless=true -jar slave.jar -jar-cache /Users/Shared/jenkins/cache -jnlpUrl http://jenkins.kodi.tv/computer/<node name from jenkins node page>/slave-agent.jnlp -secret <secret from jenkins node page>
47
4810. chmod +x /Users/Shared/jenkins/slave/startslave.sh
49
5011. edit startslave.sh and add nodename and the secret at the end of the command line from the node page
51
5212. nano /Users/Shared/jenkins/slave/org.jenkins-ci.slave.jnlp.plist and add the following
53
54<?xml version="1.0" encoding="UTF-8"?>
55<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
56<plist version="1.0">
57<dict>
58    <key>Label</key>
59    <string>com.example.ci</string>
60    <key>ProgramArguments</key>
61    <array>
62        <string>/Users/Shared/jenkins/slave/startslave.sh</string>
63    </array>
64    <key>KeepAlive</key>
65    <true/>
66    <key>RunAtLoad</key>
67    <true/>
68    <key>SessionCreate</key>
69    <true/>
70    <key>UserName</key>
71    <string>jenkins</string>
72    <key>WorkingDirectory</key>
73    <string>/Users/Shared/jenkins</string>
74    <key>StandardOutPath</key>
75    <string>/Users/Shared/jenkins/slave/stdout.log</string>
76    <key>StandardErrorPath</key>
77    <string>/Users/Shared/jenkins/slave/error.log</string>
78</dict>
79</plist>
80
8113. sudo mv /Users/Shared/jenkins/slave/org.jenkins-ci.slave.jnlp.plist /Library/LaunchDaemons/org.jenkins-ci.slave.jnlp.plist
82
8314. sudo nano /etc/profile and add PATH=$PATH:/usr/local/bin
84
8515. curl http://jenkins.kodi.tv/jnlpJars/slave.jar -Lo /Users/Shared/jenkins/slave.jar
86
8716. install java JDK 8
88
8917. Install Xcode (get it from developer.apple.com -> Downloads) and start it once (accept license):
90- 10.2 to /Applications/Xcode10.2.app - for macOS and iOS builds
91- 11.3.1 to /Applications/Xcode11.3.1.app - for tvOS builds
92
9318. install brew
94
9519. install ccache via brew (brew install ccache)
96
9720. edit /var/lib/jenkins/.ccache/ccache.conf and set max_size to 20.0G (this file might just appear after the first build done on the node)
98
9921. load service:
100sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.slave.jnlp.plist
101