1. Install the brew command first. If it has been installed before, skip it

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
Copy the code

2. Jenkins installation, rely on jdk8, run the following command to install jdk8

brew cask install homebrew/cask-versions/adoptopenjdk8
Copy the code

Install Jenkins. Homebrew will install the package in /usr/local/CELLAR and soft link it to /usr/local

brew install jenkins
Copy the code

4. Command to start/stop/restart Jenkins

# start Jenkins
brew services start jenkins
# stop Jenkins
brew services stop jenkins
# restart Jenkins
brew services restart jenkins
Copy the code

5. Open the browser, enter localhost:8080 or IP :8080, and enter the password.

Get password
cat /Users/${computer name}/.jenkins/secrets/initialAdminPassword
Copy the code

Jenkins’ default httpListenAddress is 127.0.0.1 or 0.0.0.0 for LAN access. HttpPort is 0.0.0.0 for LAN access

Open the configuration file
sudo vim /usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist

# restart Jenkins
brew services restart jenkins
Copy the code
<? xml version="1.0" encoding="UTF-8"? > <! DOCTYPE plist PUBLIC"- / / / / DTD PLIST Apple 1.0 / / EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <dict> <key>Label</key> <string>homebrew.mxcl.jenkins</string> <key>ProgramArguments</key> <array> < string > / usr/libexec/java_home < / string > < string > -v < / string > < string > 1.8 < / string > < string > - exec < / string > <string>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/>
  </dict>
</plist>
Copy the code