Jenkins 没有在 Ubuntu 中获取已更改的配置文件 (/etc/default/jenkins)

发布于 2025-01-18 10:12:46 字数 474 浏览 2 评论 0原文

使用:

  • Ubuntu 20.04.2 LTS
  • Java 1.8.0_322
  • Jenkins 2.332.1

我一直在尝试更改 /etc/default/jenkins 文件中的 HTTP 端口或用户。然而,一旦我这样做了,这些变化就不会被接受:

sudo service jenkins restart

这里的答案似乎也不起作用: Jenkins 在 /etc/default/jenkins 中的更改不起作用

sudo systemctl edit jenkins

打开一个新文件进行编辑

Using:

  • Ubuntu 20.04.2 LTS
  • Java 1.8.0_322
  • Jenkins 2.332.1

I've been attempting to change the HTTP port or the User in /etc/default/jenkins file. However the changes are not picked up once I do:

sudo service jenkins restart

The answer here also doesn't seem to work:
Jenkins changes in /etc/default/jenkins not working

sudo systemctl edit jenkins

just opens a new file for editing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风轻花落早 2025-01-25 10:12:46

编辑/etc/default/jenkins
在Jenkins版本2.332.1之后不起作用,该版本依赖于
在SystemD而不是Init System上(文档)。

相反,运行:

SystemCtl编辑Jenkins

将带有一个空文件的编辑器。创建下面的部分:

[Service]
Environment="JENKINS_PORT=8888"

根据需要更改端口并保存文件(如果Nano为编辑器,则使用ctrl + X,Y)。
最后,重新启动詹金斯,它应该接收新端口:

sudo systemctl重新启动jenkins

Editing /etc/default/jenkins
does not work after Jenkins version 2.332.1, which relies
on systemd rather than the init system (documentation).

Instead, run:

systemctl edit jenkins

which will bring up an editor with an empty file. Create the section below with the following:

[Service]
Environment="JENKINS_PORT=8888"

Change the port as desired and save the file (in case of nano as editor with Ctrl + X, Y).
Finally, restart Jenkins and it should pick up the new port:

sudo systemctl restart jenkins

对风讲故事 2025-01-25 10:12:46

使用 Debian Bullseye (Debian 11) :

vim /etc/systemd/system/jenkins.service.d/override.conf

[Service]
Environment="JENKINS_LISTEN_ADDRESS=127.0.0.1"
Environment="JENKINS_PREFIX=/jenkins"
Environment="JENKINS_PORT=XXXX"  <= Change XXXX to the port value you want to use.

关键是编辑配置文件来覆盖默认配置,因为默认配置每个新版本都会更新配置,从而删除您的自定义配置。

不要忘记使用以下命令更新并重新加载更改:

systemctl daemon-reload

service jenkins restart

With Debian Bullseye (Debian 11) :

vim /etc/systemd/system/jenkins.service.d/override.conf

[Service]
Environment="JENKINS_LISTEN_ADDRESS=127.0.0.1"
Environment="JENKINS_PREFIX=/jenkins"
Environment="JENKINS_PORT=XXXX"  <= Change XXXX to the port value you want to use.

The key is to edit the config file which is overriding the default configuration, because the default configuration is updated each new release, erasing your custom config.

Don't forget to update and reload your changes with :

systemctl daemon-reload

service jenkins restart

も让我眼熟你 2025-01-25 10:12:46
sudo systemctl edit jenkins

实际上是有效的,就像问题的链接中一样。它不会修改配置文件,但是在这里添加的任何内容覆盖可以使用以下方式查看的配置:

systemctl cat jenkins
sudo systemctl edit jenkins

Is what actually works,, as in the link in the question. It doesn't modify the config file, but anything that gets added here overwrites the config that can be viewed using:

systemctl cat jenkins
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文