当 jenkins.war 不是 运行 时,Jenkins 不是 运行
Jenkins is not running when the jenkins.war is not running
我正在尝试为我正在处理的 selenium/maven 项目自动安排 Jenkins 作业。一切正常 运行ning,只有当 .jar 文件 运行ning(使用命令:java -jar jenkins.war --httpPort=8089
)时,自动调度才会工作。但是一旦我退出命令提示符和 Jenkins 服务器,它就不会 运行 了。我假设它应该 运行 无论是否连接以及计算机正在登录或注销。
在我看来,当 jenkins.war 文件未启动且 运行ning 时,Jenkins Autoscheduling 无法正常工作。
我是不是漏掉了什么?
如果 .war
文件未被执行,则整个 jenkins
过程不会 运行ning。问题是你如何 运行 Jenkins.
有extensive documentation如何运行。但是,我最终通过 system.d
服务文件在 systemd
启用 OS (linux) 上 运行ning:/usr/lib/systemd/system/jenkins.service
:
[Unit]
Description=Jenkins
Documentation=https://wiki.jenkins.io/display/JENKINS/Use+Jenkins
After=network.target
Requires=network.target
[Service]
Type=simple
EnvironmentFile=/etc/default/jenkins
ExecStart=/home/jenkins/jdk/jdk1.8.0_121/bin/java -Xmx2048m -Xms1024m -DJENKINS_HOME=/home/jenkins -jar /home/jenkins/jenkins.war --javaHome=/home/jenkins/jdk/jdk1.8.0_121 --httpPort=8080 --webroot=/var/cache/jenkins/war --ajp13Port=-1 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
# Restart=always
# RestartSec=120
User=jenkins
[Install]
WantedBy=multi-user.target
与:/etc/default/jenkins
:
# Managed manually
JENKINS_HOME="/home/jenkins"
#JENKINS_LOGFILE="/home/jenkins/jenkins.log"
# TODO: manage JAVA_HOME through java-alternatives
JAVA_HOME="/home/jenkins/jdk/jdk1.8.0_121"
JAVA_OPTIONS="-Xmx2048m -Xms1024m"
# Web Configuration
HTTP_WEB_ROOT="/var/cache/jenkins/war"
HTTP_PORT="8080"
HTTP_LISTEN_ADDRESS="0.0.0.0"
# Jenkins Configurations
# more: https://wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+Jenkins
JENKINS_ARGS="--ajp13Port=-1 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20"
$ systemctl status jenkins
● jenkins.service - Jenkins
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; linked; vendor preset: disabled)
Active: active (running) since Wed 2021-03-31 10:08:36 EDT; 1 weeks 1 days ago
Docs: https://wiki.jenkins.io/display/JENKINS/Use+Jenkins
Main PID: 27219 (java)
Tasks: 70 (limit: 512)
CGroup: /system.slice/jenkins.service
└─27219 /home/jenkins/jdk/jdk1.8.0_121/bin/java -Xmx2048m -Xms1024m
并通过 Apache HTTP Server 发布它,通过 ProxyPath :
$ systemctl status apache
● apache2.service - The Apache Webserver
Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-02-02 12:34:05 EST; 2 months 4 days ago
Process: 30426 ExecReload=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful (code=exited, status=0/SUCCESS)
Main PID: 18524 (httpd-prefork)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 11
CGroup: /system.slice/apache2.service
使用 Apache HTTP 虚拟主机配置:
<IfDefine SSL>
<IfDefine !NOSSL>
##
## SSL Virtual Host Context
##
<VirtualHost _default_:443>
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
# ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8080/*>
Require all granted
</Proxy>
# ProxyPassMatch ^/(?\!.well-known) http://localhost:8080 nocanon
ErrorLog /var/log/apache2/error_log
TransferLog /var/log/apache2/access_log
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# You can use per vhost certificates if SNI is supported.
SSLCertificateFile /etc/apache2/ssl.crt/<your-server>.com.crt
SSLCertificateKeyFile /etc/apache2/ssl.key/<your-server>.com.key
CustomLog /var/log/apache2/ssl_request_log ssl_combined
</VirtualHost>
</IfDefine>
</IfDefine>
相同的配置设置,但通过 NGINX:Jenkins reverse-proxy configuration nginx
通过这种方式,您可以管理您的 jenkins 服务器 (start/stop) 和管理 TLS (SSL) 通信:
systemctl status jenkins nginx
如果你 运行 Jenkins 到 Docker,你不需要在 Jenkins 前面公开的另一个 WebServer(例如 Apache/NGINX),你不会暴露Jenkins Docker 容器,但您前面可能有一个 Kubernetes/(A)LB。不建议公开暴露 Jenkins。
WebServer 使您可以灵活地在 Jenkins 前面使用缓存或 CDN,尤其是当您使用 发布工件 功能时。
我正在尝试为我正在处理的 selenium/maven 项目自动安排 Jenkins 作业。一切正常 运行ning,只有当 .jar 文件 运行ning(使用命令:java -jar jenkins.war --httpPort=8089
)时,自动调度才会工作。但是一旦我退出命令提示符和 Jenkins 服务器,它就不会 运行 了。我假设它应该 运行 无论是否连接以及计算机正在登录或注销。
在我看来,当 jenkins.war 文件未启动且 运行ning 时,Jenkins Autoscheduling 无法正常工作。
我是不是漏掉了什么?
如果 .war
文件未被执行,则整个 jenkins
过程不会 运行ning。问题是你如何 运行 Jenkins.
有extensive documentation如何运行。但是,我最终通过 system.d
服务文件在 systemd
启用 OS (linux) 上 运行ning:/usr/lib/systemd/system/jenkins.service
:
[Unit]
Description=Jenkins
Documentation=https://wiki.jenkins.io/display/JENKINS/Use+Jenkins
After=network.target
Requires=network.target
[Service]
Type=simple
EnvironmentFile=/etc/default/jenkins
ExecStart=/home/jenkins/jdk/jdk1.8.0_121/bin/java -Xmx2048m -Xms1024m -DJENKINS_HOME=/home/jenkins -jar /home/jenkins/jenkins.war --javaHome=/home/jenkins/jdk/jdk1.8.0_121 --httpPort=8080 --webroot=/var/cache/jenkins/war --ajp13Port=-1 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
# Restart=always
# RestartSec=120
User=jenkins
[Install]
WantedBy=multi-user.target
与:/etc/default/jenkins
:
# Managed manually
JENKINS_HOME="/home/jenkins"
#JENKINS_LOGFILE="/home/jenkins/jenkins.log"
# TODO: manage JAVA_HOME through java-alternatives
JAVA_HOME="/home/jenkins/jdk/jdk1.8.0_121"
JAVA_OPTIONS="-Xmx2048m -Xms1024m"
# Web Configuration
HTTP_WEB_ROOT="/var/cache/jenkins/war"
HTTP_PORT="8080"
HTTP_LISTEN_ADDRESS="0.0.0.0"
# Jenkins Configurations
# more: https://wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+Jenkins
JENKINS_ARGS="--ajp13Port=-1 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20"
$ systemctl status jenkins
● jenkins.service - Jenkins
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; linked; vendor preset: disabled)
Active: active (running) since Wed 2021-03-31 10:08:36 EDT; 1 weeks 1 days ago
Docs: https://wiki.jenkins.io/display/JENKINS/Use+Jenkins
Main PID: 27219 (java)
Tasks: 70 (limit: 512)
CGroup: /system.slice/jenkins.service
└─27219 /home/jenkins/jdk/jdk1.8.0_121/bin/java -Xmx2048m -Xms1024m
并通过 Apache HTTP Server 发布它,通过 ProxyPath :
$ systemctl status apache
● apache2.service - The Apache Webserver
Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-02-02 12:34:05 EST; 2 months 4 days ago
Process: 30426 ExecReload=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful (code=exited, status=0/SUCCESS)
Main PID: 18524 (httpd-prefork)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 11
CGroup: /system.slice/apache2.service
使用 Apache HTTP 虚拟主机配置:
<IfDefine SSL>
<IfDefine !NOSSL>
##
## SSL Virtual Host Context
##
<VirtualHost _default_:443>
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
# ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8080/*>
Require all granted
</Proxy>
# ProxyPassMatch ^/(?\!.well-known) http://localhost:8080 nocanon
ErrorLog /var/log/apache2/error_log
TransferLog /var/log/apache2/access_log
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# You can use per vhost certificates if SNI is supported.
SSLCertificateFile /etc/apache2/ssl.crt/<your-server>.com.crt
SSLCertificateKeyFile /etc/apache2/ssl.key/<your-server>.com.key
CustomLog /var/log/apache2/ssl_request_log ssl_combined
</VirtualHost>
</IfDefine>
</IfDefine>
相同的配置设置,但通过 NGINX:Jenkins reverse-proxy configuration nginx
通过这种方式,您可以管理您的 jenkins 服务器 (start/stop) 和管理 TLS (SSL) 通信:
systemctl status jenkins nginx
如果你 运行 Jenkins 到 Docker,你不需要在 Jenkins 前面公开的另一个 WebServer(例如 Apache/NGINX),你不会暴露Jenkins Docker 容器,但您前面可能有一个 Kubernetes/(A)LB。不建议公开暴露 Jenkins。
WebServer 使您可以灵活地在 Jenkins 前面使用缓存或 CDN,尤其是当您使用 发布工件 功能时。