Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins does not start on macOS 10.12 (Sierra)

Tags:

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?

like image 413
Vladimir Grigorov Avatar asked Sep 30 '16 15:09

Vladimir Grigorov


People also ask

Does Jenkins work on Mac?

The macOS installer for Jenkins is maintained outside the Jenkins project. Refer to documentation based on the version of Jenkins to be run.

How do I change the default Jenkins port on a Mac?

Open the file using a text editor such as Notepad or Notepad++. Scroll down until you find the line that contains --httpPort=8080 and change the number to the port you want to set. Note: If you are using HTTPS with Jenkins, use java -jar jenkins. war --httpsPort=[port number] to change the port in the command prompt.


3 Answers

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

like image 164
mac.slusarek Avatar answered Oct 12 '22 15:10

mac.slusarek


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.

like image 33
Mig82 Avatar answered Oct 12 '22 14:10

Mig82


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à!

like image 39
Matt H Avatar answered Oct 12 '22 14:10

Matt H