一、安装homebrew
步骤见:https://blog.csdn.net/fuxiu_/article/details/125212919
二、安装jdk8(jenkins依赖)
brew install homebrew/cask-versions/adoptopenjdk8 --cask
三、安装jenkins。PS:Homebrew会将软件包安装到独立目录/usr/local/Cellar,并将其文件软链接至/usr/local
brew install jenkins
四、安装后就可以启动了。
1、启动jenkins:
brew services start jenkins
2、停止jenkins
brew services stop jenkins
3、重启jenkins
brew services restart jenkins
五、获取jenkins密码
sudo cat /Users/${你的计算机名称}/.jenkins/secrets/initialAdminPassword
六、启动jenkins后,浏览器访问localhost:8080 or 127.0.0.1:8080 ,输入密码
七、如果需要局域网访问jenkins,需要修改端口
# 打开配置文件
sudo vim /usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist
修改httpListenAddress为0.0.0.0,修改后需要重启jenkins
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/openjdk@11/bin/java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
<string>--httpListenAddress=127.0.0.1</string>
<string>--httpPort=8080</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/jenkins/error.log</string>
<key>StandardOutPath</key>
"/usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist" 25L, 801B