Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Jenkins port on macOS

I was wondering how one could change Jenkins' default port 8080. Using linux or windows, this is simply done with the configuration file. But the Mac config file of Jenkins looks completely different from the other ones.

Of course one could pass the --httpPort parameter when starting the server, but I want to do this within a config file.

Is there an option for that?

PS: Passing the Jenkins instance through apache would kinda solve the problem, but I want to change the Jenkins port.

Thanks!

like image 333
Tom Ferguson Avatar asked Aug 21 '11 15:08

Tom Ferguson


People also ask

How do I change the default Jenkins port on a Mac?

You can find this file in the Jenkins install folder (the default path is C:\Program Files\Jenkins\jenkins. xml). Open the file using a text editor such as Notepad or Notepad++. Scroll down until you find the line that contains --httpPort=8080 and change the number to the port you want to set.


2 Answers

it looks like the default way is:

#add the default parameters - this will edit /Library/Preferences/org.jenkins-ci.plist

sudo defaults write /Library/Preferences/org.jenkins-ci httpPort 7070

#stop

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

#start

sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

like image 109
alex Avatar answered Sep 20 '22 09:09

alex


Before modify the Jenkins port on macOS,you must pay attention to the way of installation of Jenkins.

Here I recommend you install Jenkins by 'Homebrew' if you want to deal with iOS project building,because you may meet some errors that the way of using .pkg to install,it's really hard to solve the problems.

I have installed Jenkins LTS by brew command:

brew install jenkins-lts

So my Jenkins plist file is here:

/usr/local/Cellar/jenkins-lts/2.121.2/homebrew.mxcl.jenkins-lts.plist

You can modify the httpPort value from default 8080 to the other value,and then save the file.

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>homebrew.mxcl.jenkins-lts</string> <key>ProgramArguments</key> <array> <string>/usr/libexec/java_home</string> <string>-v</string> <string>1.8</string> <string>--exec</string> <string>java</string> <string>-Dmail.smtp.starttls.enable=true</string> <string>-jar</string> <string>/usr/local/opt/jenkins-lts/libexec/jenkins.war</string> <string>--httpListenAddress=127.0.0.1</string> <string>--httpPort=8383</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>

sudo launchctl unload command will not work for you.You must try these commands to restart your Jenkins and make the port modification works.

brew services stop jenkins-lts brew services start jenkins-lts

ifeegoo:~ ifeegoo$ brew services stop jenkins-lts Stopping `jenkins-lts`... (might take a while) ==> Successfully stopped `jenkins-lts` (label: homebrew.mxcl.jenkins-lts) ifeegoo:~ ifeegoo$ brew services start jenkins-lts ==> Successfully started `jenkins-lts` (label: homebrew.mxcl.jenkins-lts)

Note:If you installed Jenkins LTS,you must pay attention that your command must be jenkins-lts,not jenkins.

like image 35
ifeegoo Avatar answered Sep 19 '22 09:09

ifeegoo