I'm trying to set my MAC to connect to Jenkins and be ready to build automatically. I've managed to create service that connects to Jenkins, but something is wrong.
This is my plist file:
<key>Label</key>
<string>com.example.ci</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>/Users/Shared/Jenkins/Home/my_scripts/run_jenkins.sh</string>
</array>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/Shared/Jenkins/Home/stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/Shared/Jenkins/Home/error.log</string>
this is my run_jenkins.sh:
cd /Users/Shared/Jenkins/Home/
sudo -u jenkins java -jar slave.jar -jnlpUrl http://secret.mission:8080/computer/ios-slave/slave-agent.jnlp -secret 841557ed7843ac76fe1618e375
PROBLEM:
$ /usr/bin/security find-identity -p codesigning -v
0 valid identities found
this happens when I try to build right after start-up. Of course after that build fails.
When I go sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
and then sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
the result is :
$ /usr/bin/security find-identity -p codesigning -v
[.. ]
4 valid identities found
and build is succeeded. Why is that MAC can't find those profiles when it runs from start-up and how to fix this?
EDIT
I've edited my plist file:
<key>UserName</key>
<string>jenkins</string>
<key>Label</key>
<string>com.example.ci</string>
<key>ProgramArguments</key>
<array>
<string>sudo</string>
<string>-u</string>
<string>jenkins</string>
<string>/usr/bin/java</string>
<string>-Djava.awt.headless=true</string>
<string>-jar</string>
<string>/Users/Shared/Jenkins/Home/slave.jar</string>
<string>-jnlpUrl</string>
<string>http://secret.mission:8080/computer/ios-slave/slave-agent.jnlp
</string>
<string>-secret</string>
<string>841557ed7843ac76fe1618e375
</string>
</array>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/Shared/Jenkins/Home/stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/Shared/Jenkins/Home/error.log</string>
and still same situation...
sudo .. unload/load
, I'm pretty sure it'll fail as well. You probably need to be logged in as that user so this works.~/Library/LaunchAgents
)