Skip to content

Instantly share code, notes, and snippets.

Forked from shunirr/
Last active October 30, 2019 08:18
What would you like to do?
Jenkins をOS X のログインユーザー権限のデーモンで自動起動しておく設定

Jenkins をOS X のログインユーザー権限のデーモンで自動起動しておく設定


うっかり jenkins.pkg を入れてしまった人はアンインストールする

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


mkdir -p ~/Library/LaunchAgents/
mkdir -p ~/.jenkins/
mkdir -p ~/bin/
mkdir -p ~/lib/java/


mv jenkins.plist ~/Library/LaunchAgents/
mv ~/bin/
mv jenkins.war ~/lib/java/

jenkins.plist の ${USER} と ${HOME} を書き換える

  • ${USER} -> shunirr
  • ${HOME} -> /Users/shunirr
  • みたいな感じ

launchd に登録する

launchctl load -wF -D user  ~/Library/LaunchAgents/jenkins.plist
launchctl start jenkins
# Startup script used by Jenkins launchd job.
# Mac OS X launchd process calls this script to customize
# the java process command line used to run Jenkins.
# Customizable parameters are found in
# ~/Library/Preferences/jenkins.plist
# You can manipulate it using the "defaults" utility.
# See "man defaults" for details.
defaults="defaults read /Library/Preferences/jenkins"
war=`$defaults war` || war="${HOME}/lib/java/jenkins.war"
minPermGen=`$defaults minPermGen` && javaArgs="$javaArgs -XX:PermSize=${minPermGen}"
permGen=`$defaults permGen` && javaArgs="$javaArgs -XX:MaxPermSize=${permGen}"
minHeapSize=`$defaults minHeapSize` && javaArgs="$javaArgs -Xms${minHeapSize}"
heapSize=`$defaults heapSize` && javaArgs="$javaArgs -Xmx${heapSize}"
tmpdir=`$defaults tmpdir` && javaArgs="$javaArgs${tmpdir}"
home=`$defaults JENKINS_HOME` && export JENKINS_HOME="$home"
add_to_args() {
val=`$defaults $1` && args="$args --${1}=${val}"
add_to_args prefix
add_to_args httpPort
add_to_args httpListenAddress
add_to_args httpsPort
add_to_args httpsListenAddress
add_to_args httpsKeyStore
add_to_args httpsKeyStorePassword
echo "Jenkins command line for execution:"
echo /usr/bin/java $javaArgs -jar "$war" $args
exec /usr/bin/java $javaArgs -jar "$war" $args
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment