Skip to content

Instantly share code, notes, and snippets.

@pysysops
Last active January 8, 2020 20:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pysysops/090802cbc9eafd78ec9d to your computer and use it in GitHub Desktop.
Save pysysops/090802cbc9eafd78ec9d to your computer and use it in GitHub Desktop.
LaunchAgent configuration for Jenkins Swarm Agent ( https://wiki.jenkins-ci.org/display/JENKINS/Swarm+Plugin ) to run on Mac OS X.
<?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>Disabled</key>
<false/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>jenkins-swarm.job</string>
<key>LimitLoadToSessionType</key>
<string>Aqua</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-jar</string>
<string>/Users/jenkins/JENKINS/swarm-client-2.0-jar-with-dependencies.jar</string>
<string>-mode</string>
<string>normal</string>
<string>-executors</string>
<string>8</string>
<string>-username</string>
<string>aUser</string>
<string>-password</string>
<string>aPassword</string>
<string>-name</string>
<string>uk-man-prd-jnk-004</string>
<string>-master</string>
<string>http://192.168.202.220:8080</string>
<string>-labels</string>
<string>mac ios osx</string>
<string>-fsroot</string>
<string>/Users/jenkins/JENKINS</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/jenkins-swarm.job.err</string>
<key>StandardOutPath</key>
<string>/tmp/jenkins-swarm.job.out</string>
<key>WorkingDirectory</key>
<string>/Users/jenkins/JENKINS</string>
</dict>
</plist>
@pysysops
Copy link
Author

I initially had trouble with fastlane and keychains getting into an infinite loop of errors like:

17:39:53 [17:39:53]: Cloning remote git repo...
17:39:53 [17:39:54]: Enter the passphrase that should be used to encrypt/decrypt your certificates
17:39:53 [17:39:54]: This passphrase is specific per repository and will be stored in your local keychain
17:39:53 [17:39:54]: Make sure to remember the password, as you'll need it when you run match on a different machine
17:39:53 Passphrase for Git Repo: 
17:39:53 Type passphrase again: 
17:39:53 security: SecKeychainAddInternetPassword <NULL>: write permissions error

For a moment I had to be talked down from the ledge of my office building... Then I found my issues were as I ran the Agent as a "Service Agent" which, although running as the Jenkins user, wasn't running in the correct SessionType.

After re-configuring the Agent to run as a UserAgent and ensuring SessionType was "Aqua" (wtf is that anyway?) I could use commands like:

security -v unlock-keychain -p "aGoodSecret" "/Users/jenkins/Library/Keychains/login.keychain"

In my build jobs / scripts and it fricking worked! And I cried with tears of joy!

Hope this helps some of you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment