- Go to C:\Program Files (x86)\Jenkins (I’m using Windows Server 2012 and assuming it’s installed to default location)
- Open Jenkins.xml
- Edit the –httpPort argument (you may need to edit default permissions)
- Restart the Jenkins service
- Now Jenkins will permanently use the new port
There are various other solutions via the command prompt but this one just seems so much simpler and based on various other posts Jenkins seems to do a better job of remembering if you do it this way.
Probably the shortest tutorial I’ll ever write.
I love Jenkins.
I love Jenkins. It’s so simple. You download it, point it at your VCS and tell it what to do. It just works.
I am always installing CI servers on VM images for a variety of reasons and I always run into the same issue. It’s also an issue that I know my customers run into quite a bit. Jenkins really loves port 8080.
Now Jenkins isn’t the only browser based tool that does. TFS is the same. Red Gate SQL Monitor uses 8080 too, although it is smart enough to pick a different port if 8080 is already taken. Jenkins isn’t so smart. This can cause issues if port 8080 is already in use.
I’ve often had to go into IIS to try and work out what’s going on. And then, once I’ve found Jenkins and reset the binding I’ll do a reboot and Jenkins will switch back to port 8080. Jenkins, I love you, but I wish there was an easy setting in the installer to pick a different port.
Anyway – as much as I moan – it turns out the solution is pretty simple if you know where to look. I discovered this by trawling for an answer on Stack Overflow.
All you need to do is go to C:\Program Files (x86)\Jenkins (assuming you used default settings) and open up the Jenkins.xml folder. Near the end you’ll find an interesting little piece of XML:
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>
You can probably guess what to do… You’ll need to restart the Jenkins service but once you edit the httpPort argument Jenkins will run on whatever port you specify. Permanently.
You’ll probably need to edit the default file permissions (right-click>Properties>Security).
That’s all folks. I knew the answer would be simple – if you just knew where to look. Jenkins is good like that.