Configuring Jenkins to start automatically at boot on MacOS

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:

  1. Open the Terminal application

  2. Enter the Jenkins installation directory. like: /Users/Shared/Jenkins

    cd /Users/Shared/Jenkins
    
  3. Open the jenkins.plist file with a text editor

    sudo nano jenkins.plist
    
  4. 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.

  5. Save and close the file.

  6. Copy the jenkins.plist file to the LaunchAgents directory using the following command:

    sudo cp jenkins.plist /Library/LaunchAgents/
    
  7. 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
    
  8. Load and start Jenkins using the following commands:

    launchctl load /Library/LaunchAgents/jenkins.plist
    
  9. 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~~~

Guess you like

Origin blog.csdn.net/m0_54701273/article/details/134946127