Changing Jenkins Port on CentOS 7

Alternative Method: Changing Jenkins Port Using systemctl

Jenkins Logo

In addition to editing the Jenkins configuration file directly, there's an alternative method mentioned in the Jenkins documentation that allows you to change the port using systemctl. This approach is particularly useful when you need to make a quick adjustment without directly editing configuration files.

  1. Open a terminal on your CentOS 7 server.
  2. If Jenkins fails to start because a port is in use, you can use systemctl to edit the Jenkins service:

bash

                               sudo systemctl edit jenkins

This command will open a text editor where you can add configuration options for the Jenkins service. Add the following lines to specify the new port (for example, changing it to port 8081):

[Service]

Environment="JENKINS_PORT=8081"

Save the file and exit the text editor.

Restart the Jenkins service to apply the changes:

                    bash

       sudo systemctl restart jenkins

 

Verify the port change by accessing Jenkins in your web browser using the new port number. For example, if you set the port to 8081, you can access Jenkins at http://your_server_ip:8081.

This method provides a convenient way to change the Jenkins port without directly editing the configuration files. It's especially useful when you need to make a temporary adjustment or if you prefer not to modify the configuration files directly.


 

Previous Post Next Post