I have written in a previous article how to realize the self-starting of Jenkins through the combination of vbs+bat script in the Windows environment. Recently, I changed my computer and I have to set up Jenkins again. By the way, I will share how to configure the self-starting of Jenkins on MacOS. method.
Specific configuration steps:
-
Open the Terminal application
-
Enter the Jenkins installation directory. like:
/Users/Shared/Jenkins
cd /Users/Shared/Jenkins
-
Open the
jenkins.plist
file with a text editorsudo nano jenkins.plist
-
In the opened file, write the following:
<?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>Label</key> <string>org.jenkins-ci</string> <key>ProgramArguments</key> <array> <string>/usr/bin/java</string> <string>-jar</string> <string>/Users/Shared/Jenkins/jenkins.war</string> <string>--httpPort=8080</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
Note: Make sure the path in the
<string>/Users/Shared/Jenkins/jenkins.war</string>
part points correctly to your Jenkins installation directory. -
Save and close the file.
-
Copy the
jenkins.plist
file to theLaunchAgents
directory using the following command:sudo cp jenkins.plist /Library/LaunchAgents/
-
Change the owner and permissions of the
jenkins.plist
file using the following commands:sudo chown root /Library/LaunchAgents/jenkins.plist sudo chmod 644 /Library/LaunchAgents/jenkins.plist
-
Load and start Jenkins using the following commands:
launchctl load /Library/LaunchAgents/jenkins.plist
-
Jenkins will be configured to run automatically when the system starts. Verify: access Jenkins (default address is
http://localhost:8080
) after restarting the computer to start successfully.
OVER~~~