Vlad Grigorov
Vlad Grigorov

Reputation: 11378

Jenkins does not start on macOS 10.12 (Sierra)

After upgrading my macOS to Sierra, when I start Jenkins using launchctl load I cannot connect to localhost:8080. If I call launchctl load again, I see response "service already loaded". There is no log file at the default location /var/log/jenkins/ (as set in jenkins-ci.plist). I also tried to create jenkins.log there and chown to jenkins user, but still nothing is printed there.

If I try to start Jenkins using java -jar jenkins.war, I can connect to localhost, but Jenkins runs as a new installation.

I have the latest JRE 1.8.0_102 installed.

How to diagnose the problem?

Upvotes: 22

Views: 26214

Answers (9)

Tapan Hegde
Tapan Hegde

Reputation: 1328

I was facing issue in loading jenkins-cli.plist command on my MacOs(Mojave version).

Mac Version : Mojave 10.14.6 Jenkins Version : 2.190.1

I installed jenkins using .pkg file.

Reference link : https://java2blog.com/install-jenkins-mac-os-x/

When executing below command,

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

I was facing error saying "already loaded".

Solution:

step 1. Check jenkins logs for exact error.

tail -f /var/log/jenkins/jenkins.log

(In my case, it was port binding issue, port 8080 was already being used by some other application)

step 2. So I decided to start jenkins on some other port (say 7070).You can do this by using below commands.

sudo defaults write /Library/Preferences/org.jenkins-ci.plist httpPort 7070

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

step 3. Try to access it in browser, http://localhost:7070. It should work!!

Upvotes: 3

Mark Thormann
Mark Thormann

Reputation: 2617

In my case, the install on Catalina (OSX 10.15) somehow didn't even create the /var/log/jenkins file. I had to

sudo mkdir /var/log/jenkins

and then take ownership and then Jenkins started normally. Just did the normal OSX installer so not sure why the install was corrupt.

Upvotes: 9

Matt H
Matt H

Reputation: 6532

I fixed it by setting the appropriate JAVA_HOME variable. The way I diagnosed it was to look at the errors that were thrown as Jenkins was trying to run:

tail -f /var/log/jenkins/jenkins.log

Then I tried to run it:

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

If it says it's already loaded, unload it first:

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

Then run it:

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

The error I saw was that Jenkins needed Java 8, not Java 10. So I unloaded:

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

and then installed Java 8. Then I edited the plist file:

sudo nano /Library/LaunchDaemons/org.jenkins-ci.plist

and added the appropriate JAVA_HOME environment variable:

<dict>
   <key>JENKINS_HOME</key>
   <string>/Users/Shared/Jenkins/Home</string>
   <key>JAVA_HOME</key>
   <string>/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home</string>
</dict>

Finally, I tried the launchctl command again:

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

and voilà!

Upvotes: 10

Larry Ricker
Larry Ricker

Reputation: 319

This same thing happened to me when I upgraded from Sierra to High Sierra. I followed the instructions outlined above by mac.slusarek, however the jenkins ID no longer existed on my computer. I created the jenkins id as a Standard user. Also, the files under /Users/Shared/Jenkins were no longer owned by jenkins. After I cat out the error log with the command:

sudo cat /var/log/jenkins/jenkins.log

After seeing the error:

Exception in thread "main" java.io.IOException: Jenkins has failed to create a 
temporary file in /Users/Shared/Jenkins/tmp
    at Main.extractFromJar(Main.java:368)
    at Main._main(Main.java:210)
    at Main.main(Main.java:112)
 Caused by: java.io.IOException: Permission denied
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createTempFile(File.java:2024)
    at Main.extractFromJar(Main.java:365)
    ... 2 more

I fixed the ownership with the command:

sudo chown -R jenkins /Users/Shared/Jenkins

Upvotes: 4

Mig82
Mig82

Reputation: 5478

This happened to me when I upgraded to Sierra and I managed to solve it with the answer from @mac.slusarek . But it happened again recently. This time I had allowed a minor update of the OS and I had also been playing around with SDK Man to switch JDK's. Not sure which one broke my Jenkins but this time around it was not a permissions issue.

I noticed from the logs Jenkins was trying to run on Java 9-ea, which is apparently not supported yet. I had installed Jenkins using the Jenkins installer for Mac, so tried uninstalling:

/Library/Application\ Support/Jenkins/Uninstall.command

and installing again but the issue didn't go away.

Then I found this article suggesting to instead install it using Homebrew. It was as easy as running:

$brew install jenkins

Since I only run it locally for development I don't need to start it as a daemon, so now I just run it by typing

$jenkins

Problem solved. I hope this helps others.

Upvotes: 18

Zumry Mohamed
Zumry Mohamed

Reputation: 9558

I had the same problem.

I manually enabled the read + write access to the

/Users/Shared/Jenkins 

Folder.

Upvotes: 3

mac.slusarek
mac.slusarek

Reputation: 693

Seems that Sierra changed the permission of Jenkis folder. So the best solution is:
1. Add execute permissions to org.jenkins-ci.plist:
sudo chmod +x /Library/LaunchDaemons/org.jenkins-ci.plist
2. Set jenkins as the owner of /var/log/jenkins:
sudo chown jenkins /var/log/jenkins
3. Start Jenkins:
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Upvotes: 55

Werdeil
Werdeil

Reputation: 101

I had the same issue, installing the JDK didn't made the trick

However changing the rights of the log directory (in my case /var/log/jenkins) and restarting Jenkins worked.

Seems that moving to Sierra changed the rights on this folder.

Upvotes: 9

Vlad Grigorov
Vlad Grigorov

Reputation: 11378

As I mentioned in the question, I had JRE installed. After I installed JDK, Jenkins is able to start normally.

Upvotes: 5

Related Questions