-
Improvement
-
Resolution: Unresolved
-
Major
-
None
JENKINS-9399 changed the Jenkins from using LaunchAgents to LaunchDaemons because, at the time, there were problems with running as an agent and using LaunchDaemons seems like the right approach.
Two years later, it's pretty clear that using LaunchDaemons creates a whole host of problems which (I argue) are worse than using LaunchAgents in the first place. LaunchDaemons cannot launch GUI applications which means you cannot unit test iOS applications or launch with XCode "instructions"... both of which are in high demand.
Anyway, I believe I discovered a way for us to have the best of both worlds: using LaunchAgents, having it auto-launch on boot, and preventing it from running under other users. I believe this will solve all outstanding problems.
- Configure Jenkins to use LaunchAgents (reverse
JENKINS-9399). - Install the plist into ~/Library/LaunchAgents instead of /Library/LaunchAgents to prevent it from getting triggered by other users logging in.
- Configure the Jenkins user to auto-login on startup, but return to the login menu immediately: http://www.tuaw.com/2011/03/07/terminally-geeky-use-automatic-login-more-securely/
It has been years since I last played with PackageMaker but I believe it was possible to build a package that will query if you want to install for all users or for current user only. If all users is chosen, the installer will prompt for admin password. It might be possible to determine which kind of installation happened in a post install script and place the launchd plist file in a location that either makes Jenkins be a launch daemon or launch agent.
However, I think it would be rude to unconditionally configure the current user's account such that after login he is immediately presented with the login screen again. It should at least be configurable (= ask the user) but how to do that with PackageMaker... I have no idea.
Actually I am really tired with PackageMaker. I believe a better user experience is achieved by creating an application, a single icon the user drags where he wants and runs by double-clicking. The application can then have a conversation with the user or present a rich UI to configure and run Jenkins. If a launch agent or daemon is needed, the application can set those up.
So, personally, rather than fight with the limitations of PackageMaker, I would rather improve Jenkins.app. I'm happy to collaborate on it (pull requests are welcome.) Jenkins.app is my own project but if people feel it should be in the official Jenkins git repository, I can renew my request to accept it there.
I have kept it outside of the official Jenkins tree because I assumed most people were happy with the PackageMaker based installer which runs Jenkins as a launch daemon. It has it's problems but there are workarounds and plugins like the Xcode plugin which should provide some relief.