/etc/default/jenkins中的Jenkins更改不起作用

omqzjyyz  于 2023-02-07  发布在  Jenkins
关注(0)|答案(3)|浏览(326)

我在Ubuntu 20.04 LTS上运行Jenkins,我想更改端口或Jenkins运行的用户,但在重新启动服务后,对/etc/default/jenkins文件的更改不会更改端口。
服务仍以下列方式启动:

/usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080

当/etc/default/jenkins文件显示:

[...]
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8081

# servlet context, important if you want to use apache proxying
PREFIX=/$NAME

# arguments to pass to jenkins.
# full list available from java -jar jenkins.war --help
# --javaHome=$JAVA_HOME
# --httpListenAddress=$HTTP_HOST (default 0.0.0.0)
# --httpPort=$HTTP_PORT (default 8080; disable with -1)
# --httpsPort=$HTTP_PORT
# --argumentsRealm.passwd.$ADMIN_USER=[password]
# --argumentsRealm.roles.$ADMIN_USER=admin
# --webroot=~/.jenkins/war
# --prefix=$PREFIX

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"

我检查了两台不同的Ubuntu 20.04 LTS机器,都有同样的问题。有人知道我做错了什么吗?

kcugc4gi

kcugc4gi1#

在jenkins 2.332.1之后..不再使用/etc/default/jenkins. jenkins现在是用systemd配置的.你可以检查systemctl cat jenkins查看选项和systemctl edit jenkins修改它..
您可以更改端口。

[Service]
Environment="JENKINS_PORT=8081"

已更新java内存和java参数环境=“JENKINS_OPTS=”

Environment="JENKINS_OPTS=-Xmx2048m"
gzszwxb4

gzszwxb42#

同样的问题,今天我刚把jenkins升级到v2.332.1(在Ubuntu 20.04.1 LTS上),我稍微修改了/etc/default/jenkins -更新了java内存和java参数:

...
# arguments to pass to java
JAVA_MEMORY="-Xmx2048m"

# Allow graphs etc. to work even when an X server is present
JAVA_ARGS="${JAVA_MEMORY} -Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-scripts allow-same-origin; default-src 'none'; img-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; font-src 'self'; media-src 'self'\""
...

但是在使用“systemctl restart jenkins”重新启动服务后,它并没有使用新的参数,似乎只是忽略了/etc/default/jenkins

jenkins  1774584       1 42 19:07 ?        00:07:14 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
nfs0ujit

nfs0ujit3#

更新/etc/systemd/system/jenkins.service.d/override.conf并运行systemctl daemon-reload

相关问题