一尘不染

不同HTTP端口(Mac OS X)上的多个Jenkins守护程序

jenkins

如何在Mac OS X系统上的不同HTTP端口(即7070和7071)上运行两个Jenkins守护程序。

1)我为每个dameon创建两个帐户,其中包含Jenkins主目录:jeankins1,jenkins2

2)我复制默认的dameon配置文件

sudo cp /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchDaemons/jenkins-dameon-1.plist
sudo cp /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchDaemons/jenkins-dameon-2.plist

3)我修改dameon配置文件

sudo vi /Library/LaunchDaemons/jenkins-dameon-1.plist

jenkins-dameon-1.plist文件的内容:

<?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>EnvironmentVariables</key>
        <dict>
                <key>JENKINS_HOME</key>
                <string>/Users/jenkins1/Jenkins/Home</string>
        </dict>
        <key>GroupName</key>
        <string>wheel</string>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>org.jenkins-ci</string>
        <key>ProgramArguments</key>
        <array>
                <string>/bin/bash</string>
                <string>/Library/Application Support/Jenkins/jenkins-runner.sh</string>
                <string>--httpPort=7070</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>jenkins1</string>
        <key>SessionCreate</key>
        <true />
</dict>

sudo vi /Library/LaunchDaemons/jenkins-dameon-2.plist

jenkins-dameon-2.plist文件的内容:

<?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>EnvironmentVariables</key>
        <dict>
                <key>JENKINS_HOME</key>
                <string>/Users/jenkins2/Jenkins/Home</string>
        </dict>
        <key>GroupName</key>
        <string>wheel</string>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>org.jenkins-ci</string>
        <key>ProgramArguments</key>
        <array>
                <string>/bin/bash</string>
                <string>/Library/Application Support/Jenkins/jenkins-runner.sh</string>
                <string>--httpPort=7071</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>jenkins2</string>
        <key>SessionCreate</key>
        <true />
</dict>

4)我启动两个Jenkins守护程序

sudo launchctl load /Library/LaunchDaemons/jenkins-dameon-1.plist
sudo launchctl load /Library/LaunchDaemons/jenkins-dameon-2.plist

我通过httpPort参数传递的方式似乎不正确,该怎么办?


阅读 218

收藏
2020-07-25

共1个答案

一尘不染

在我的PLIST文件中,不再使用jenkins-runner.sh脚本,而是使用Java可执行文件。

jenkins-dameon-1.plist文件的内容:

<?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>EnvironmentVariables</key>
    <dict>
        <key>JENKINS_HOME</key>
        <string>/Users/jenkins1/Jenkins/Home</string>
    </dict>
    <key>GroupName</key>
    <string>daemon</string>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>jenkins1</string>
    <key>ProgramArguments</key>
    <array>
                <string>/usr/bin/java</string>
                <string>-jar</string>
                <string>/Applications/Jenkins/jenkins.war</string>
                <string>--httpPort=7070</string>
                <string>--ajp13Port=-1</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>UserName</key>
    <string>jenkins1</string>
        <key>SessionCreate</key>
    <true />
</dict>
</plist>

jenkins-dameon-2.plist文件的内容:

<?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>EnvironmentVariables</key>
    <dict>
        <key>JENKINS_HOME</key>
        <string>/Users/jenkins2/Jenkins/Home</string>
    </dict>
    <key>GroupName</key>
    <string>daemon</string>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>jenkins2</string>
    <key>ProgramArguments</key>
    <array>
                <string>/usr/bin/java</string>
                <string>-jar</string>
                <string>/Applications/Jenkins/jenkins.war</string>
                <string>--httpPort=7071</string>
                <string>--ajp13Port=-1</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>UserName</key>
    <string>jenkins2</string>
        <key>SessionCreate</key>
    <true />
</dict>
</plist>
2020-07-25