Jenkins - How to change Jenkins PORT

Опубликовано: 05 Ноябрь 2024
на канале: DevOpsExplorers
46
3

To change the port that Jenkins uses, you'll need to update the configuration files for Jenkins. By default, Jenkins runs on port 8080, but you may want to change it for various reasons, such as avoiding conflicts with other services or meeting security requirements. Here's how you can change the port:

Note: Before making any changes, make sure you have administrative access to your Jenkins server, and it's recommended to create a backup of your Jenkins configuration.

Stop Jenkins: If Jenkins is running, you should stop it before making any configuration changes. You can do this using your operating system's service management tools or by using the Jenkins command-line interface.

Locate the Jenkins Configuration File:
The configuration file for Jenkins is typically named jenkins.xml and is located in the Jenkins home directory. The location of this directory varies depending on your operating system.

Linux/Unix: The configuration file is often located at /var/lib/jenkins/jenkins.xml.
Windows: It may be in a directory like C:\Program Files (x86)\Jenkins.
Edit the Configuration File:
Open the jenkins.xml file in a text editor of your choice.

Locate the HTTP Port Configuration:
In the configuration file, look for a section that looks like this:

xml
Copy code
connector
httpPort8080/httpPort
/connector
The httpPortelement specifies the port that Jenkins listens on. Change the 8080 to the desired port number. For example, if you want Jenkins to listen on port 9090, change it to:

xml
Copy code
httpPort9090/httpPort
Save and Close the File:
After making the change, save the jenkins.xml file and close the text editor.

Start Jenkins:
Once you've saved the configuration file, start Jenkins again. If you stopped it in step 1, you can use your operating system's service management tools or run the appropriate command to start Jenkins.

Access Jenkins Using the New Port:
After Jenkins has started, you should be able to access it using the new port in your web browser. For example, if you changed the port to 9090, you would access Jenkins at http://your-server-ip:9090.

Remember to update any firewall rules or security groups to allow traffic on the new port if your server has a firewall configured. Additionally, be cautious when changing ports, as it can affect how other services and tools interact with Jenkins, so ensure that any integrations or scripts are updated accordingly.