1

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

TeabagD
  • 569
  • 6
  • 17

3 Answers3

5

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

Chris
  • 5,876
  • 3
  • 43
  • 69
Barath Kumar
  • 116
  • 3
1

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

BendaThierry.com
  • 2,080
  • 1
  • 15
  • 17
  • 1
    I'm doing it using Ansible, and `systemctl daemon-reload` was the key point to grab the override.conf file. Thanks. – Signor May 17 '23 at 21:39
0
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
TeabagD
  • 569
  • 6
  • 17