Apri
Apri

Reputation: 1515

Can't get jenkins to run on different port on Ubuntu 20.4

I rented a VPS on digitalocean that runs on Ubuntu 20.4. I installed jenkins following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-18-04. I exactly followed the instructions.

I want to run a Spring Boot App on this server and build a CI/CD pipeline with jenkins. I want the Spring Boot App to run on port 8080, so I need to move jenkins, which defaults to 8080. I found this answer which seemed to work for everyone in the thread:

First open the /etc/default/jenkins file. Then under JENKINS_ARGS section, you can change the port like this HTTP_PORT=9999.

Then you should restart Jenkins with sudo service jenkins restart.

Then to check the status use this command sudo systemctl status jenkins

I exactly followed those few steps, but somehow Jenkins still runs on Port 8080. Is there something I've missed?

Upvotes: 1

Views: 2174

Answers (1)

davidpace
davidpace

Reputation: 435

Editing /etc/default/jenkins does not work anymore since 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. Paste the following contents:

[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

Upvotes: 3

Related Questions