重要提示: 强烈建议使用命令行进行安装,使用安装包dmg安装会有很多权限问题无法解决
你已安装了homebrew,就跳过下面这一步
1、安装brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、安装jenkins
brew install jenkins
3、链接launchd配置文件
ln -sfv /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents
对launchd配置文件的知识
在Mac下没有像Linux那样有很多的关于init方面的工具,从init的发展历史https://en.wikipedia.org/wiki/Init上可以知道,Mac使用的是Launchd作为init管理工具,对应的命令工具为launchctl。如果在Linux下创建一个自启动服务可以使用Upstart、Systemd、Sysvinit,其中最简单和最古老的方式应该是Sysvinit,毕竟其支持Shell脚本,非常方便。而在Mac下,与Linux的做法不太一样,采用Launchd进行管理,其设置服务采用了plist文件进行对服务来描述,并通过配置好后放在/System/Library/LaunchDaemons
或者/Library/LaunchDaemons,最后通过launchctl命令行使其生效,期间也可以直接通过launchctl来对服务进行操作,比如启动、停止等。
详细的plist编写规范及介绍,参考:https://en.wikipedia.org/wiki/Launchd
4、启动jenkins
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
5、关闭jenkins
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
登录