29

Under OS X 10.9 Jenkins CI was being automatically started by launchd. After update to 10.10, it is no longer being started.

Jenkins was installed using the OS X installer from jenkins-ci.org. I was running v1.584. After this problem surfaced I reinstalled using v1.585 to no avail.

There is no output in the log file specified in org.jenkins-ci.plist. Syslog has several messages indicating that the org.jenkins-ci service "could not initialize: 14A389: xpcproxy + 14045 [1344][1016C726-9ACF-3A24-9C51-A279F5C6B167]: 0xd".

What's changed in Yosemite that broke jenkins?

Is the "0xd" at the end of the log message an error code?

I tried manually loading and starting via launchctl. No errors were output to the console but jenkins is still not running.

The problem is not unique to Jenkins. I have another launchd item that also fails since the update to 10.10: TrendMicro anti-virus.

msc
  • 1,549
  • 2
  • 12
  • 19
  • 2
    I should note that there is another problem that must be fixed before the problem in this question is hit. The installation of 10.10 removes the old Apple JDK6 and leaves the /usr/bin/java* links dangling. These links are used when running Java from the command line, as jenkins-runner.sh does. To fix this, it is necessary to install a JDK from Su^H^HOracle. It must be a JDK as the JRE does not install in the location pointed at by the links in /usr/bin. Changing the links is not recommended as they are installed as part of OS X. – msc Oct 21 '14 at 10:03

4 Answers4

50

Here is the definitive answer.

  1. Ensure you have Java installed. The 10.10 installer, at least in my case, removed Apple's Java 6. The installed java must satisfy the /usr/bin/java* links. These point to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands. When installing Oracle Java you need the JDK not the JRE to meet this requirement.

  2. chown jenkins /var/log/jenkins/jenkins.log

  3. Make sure /var/log/jenkins is owned by jenkins and searchable by anyone (mode 755). It will likely already be in this state.

  4. Edit the file /etc/newsyslog.d/jenkins.conf, changing

    /var/log/jenkins/jenkins.log 644 3 * $D0 J

    to

    /var/log/jenkins/jenkins.log jenkins:jenkins 644 3 * $D0 J

    This ensures that new log files created during nightly log rotation are owned by jenkins. If you do not do this, you will need to repeat step 2 every day.

Step 4 of @kjones answer is likely unnecessary as launchd attempts to start jenkins every 10 seconds.

The '0xd' at the end of the log message I posted is indeed the error code: Permission Denied.

What changed in launchd? /var/log/jenkins/jenkins.log is specified as the Standard{Error,Out}Path in org.jenkins-ci.plist. My theory is that prior to Yosemite launchd opened the file and set up STDOUT & STDERR before changing the process owner to "jenkins" and running jenkins-runner.sh. In Yosemite, it seems launchd does not open the file until after it has changed the process ownership, hence "permission denied" when the file is owned by root.

msc
  • 1,549
  • 2
  • 12
  • 19
  • 3
    combining 2 and half of 3, `sudo chown -R jenkins:jenkins /var/log/jenkins/` worked for me (before finding this thread). Also, this is reported/tracked in issue tracking as [JENKINS-23543](https://issues.jenkins-ci.org/browse/JENKINS-23543) (the comments of which are how I found this). – Scott Heaberlin Nov 01 '14 at 19:50
  • `sudo chmod 755 /var/log/jenkins` did the job. thanks! – Fenix Voltres Jan 27 '15 at 18:14
  • one up, for the "persistent" part, really saved me from changing the owner each day ;-) – d4Rk Feb 04 '15 at 07:39
  • After doing all this I still had an error because jenkins did not have permission to write to /Users/Shared/Jenkins/tmp. Performing step 2 on that directory solved that final issue and 10 seconds later jenkins loaded! I encourage anyone who still has the problem after following the guide to look in the jenkins log for clues. – Marmoy Apr 09 '15 at 07:37
  • Did you find a list of `0x-` error codes somewhere, or how did you figure out that it was 'Permission Denied'? – adamyonk Jun 27 '16 at 22:09
  • The list is in /usr/include/sys/errno.h on all Unix and Unix-like systems. The values are given in decimal not hex though. Given the presentation of the value in syslog as a merely "0xd", I wasn't absolutely sure, until I had figured out cause of the problem, that is *was* an error code. – msc Sep 26 '16 at 16:53
17

Here are the steps I had to take:

  1. Install Apple's OS X Java

  2. Add execute permissions to org.jenkins-ci.plist

    sudo chmod +x /Library/LaunchDaemons/org.jenkins-ci.plist

  3. Set jenkins as the owner of /var/log/jenkins

    sudo chown jenkins /var/log/jenkins

  4. Start Jenkins

    launchctl start /Library/LaunchDaemons/org.jenkins-ci.plist

kjones
  • 5,783
  • 2
  • 27
  • 27
  • thanks for the hint that sent me in the right direction. Due to limitations of comment editing, I'll post another answer with complete details. – msc Oct 22 '14 at 02:02
  • It seems like I can get by with steps 1 and 3 only (then login again). (Was step 1 really required? I don't know...) – David Oct 22 '14 at 02:11
  • Not sure if step 1 was required. If you have another version of java installed it may not be needed. – kjones Oct 22 '14 at 17:00
  • Step 2 is not needed, and actually not a good practice to +x something that will not execute. – Juan Carlos Méndez Oct 29 '14 at 21:12
  • Yes - Step 2 is not needed. I was honestly just taking a stab at getting jenkins to start and the attributes on another .plist in the LauchDaemons directory (com.oracle.java.Helper-Tool.plist) was marked as exectuable. I'll edit my response. – kjones Oct 29 '14 at 21:43
  • I ran /Library/Application\ Support/Jenkins/jenkins-runner.sh in background and it worked like a charm for me. If you cat /Library/LaunchDaemons/org.jenkins-ci.plist, you will see the shell script there :) – Mayur Nagekar Feb 24 '15 at 15:33
  • Step 2 fixed my issues up when updating my OS from Sierra to High Sierra! – RyanG Aug 06 '18 at 12:48
  • OMG MISSING STEP 4! Thanks – Deividi Cavarzan Mar 24 '19 at 18:17
2

This fixed the issue at my end :

1) Obtained the latest java update for java 8 from https://www.java.com/en/download/help/mac_10_10.xml

2) sudo chown jenkins /var/log/jenkins/jenkins.log

3) sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Mayur Nagekar
  • 813
  • 5
  • 13
-1

Might no longer be needed. I downloaded jenkins-1.588 from http://jenkins-ci.org, chose the Mac OS X native package, ran the installer, see in in Applications/Jenkins, and it runs. I am running 10.10 (14A389).

  • Hmm... The matching [issue](https://issues.jenkins-ci.org/browse/JENKINS-23543) in the Jenkins issue tracker is still open. Had you previously applied the fixes listed here or was this a new jenkins installation? I am running the same Yosemite version as you. – msc Nov 06 '14 at 01:57
  • New Jenkins installation. – Frank Cohen Nov 06 '14 at 03:58
  • 2
    Yes. A new installation will work until `newsyslog` rotates the log files. This is because the initial installation does not create `/var/log/jenkins/jenkins.log`. It is created by launchd when it first runs `jenkins-ci.plist` so it will be owned by jenkins. Log rotation changes ownership to root. – msc Nov 11 '14 at 02:25
  • I still experienced this issue on jenkins 1.608. Also, the problem is not that jenkins does not run if you manually launch it from /Applications/Jenkins, the problem is that it does not launch using launchd – Marmoy Apr 09 '15 at 06:59