Tom Ferguson
Tom Ferguson

Reputation: 903

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!

Upvotes: 55

Views: 45159

Answers (7)

Maaz Hasan
Maaz Hasan

Reputation: 11

Just write the following command in the terminal:

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

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

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

That should resolve it.

Upvotes: 1

ifeegoo
ifeegoo

Reputation: 7302

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.

Upvotes: 38

Pratik Patel
Pratik Patel

Reputation: 2451

I have installed Jenkins on my Mac OS High Sierra using Brew.

Please follow below steps:

  1. You have to change the port to below file:

    /usr/local/Cellar/jenkins/2.x.x/homebrew.mxcl.jenkins.plist

  2. Assign any free port like 7070 or any number you want.[If you have static IP then you can give port 80(HTTP)]

    --httpPort=7070

  3. You also need to restart the Jenkins Server. using below brew service commands:

    $ brew services stop jenkins

    $ brew services start jenkins

That's all.!

Upvotes: 5

uopeydel
uopeydel

Reputation: 441

This worked for me for changing port to 7070 or other.

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

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

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

More info about this

Upvotes: 13

alex
alex

Reputation: 1611

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

Upvotes: 161

St&#233;phane B.
St&#233;phane B.

Reputation: 3290

An other solution in case of running two daemons of Jenkins, on different HTTP ports (i.e. 7070 and 7071) : Multiple Jenkins daemons on different HTTP ports (Mac OS X)

Upvotes: 0

Andrew T Finnell
Andrew T Finnell

Reputation: 13638

I'll walk you through it:

cd /Applications/Jenkins sudo vi winstone.properties Add httpPort=9999 to the file. To see all the options you can put in there type java -jar jenkins.war --help

run java -jar jenkins.war from /Applications/Jenkins. Your port will be changed. jenkins.war picks up config options from ./winstone.properties by default.

Andrew-Finnells-MacBook-Pro:Jenkins afinnell$ pwd
/Applications/Jenkins
Andrew-Finnells-MacBook-Pro:Jenkins afinnell$ ls -al
total 87928
drwxr-xr-x   4 root  wheel       136 Aug 21 12:32 .
drwxrwxr-x+ 83 root  admin      2822 Aug 21 12:05 ..
-rwxr-xr-x   1 root  wheel  45014470 Aug 19 13:14 jenkins.war
-rw-r--r--   1 root  wheel        14 Aug 21 12:32 winstone.properties
Andrew-Finnells-MacBook-Pro:Jenkins afinnell$ sudo cat winstone.properties 
httpPort=9494
Andrew-Finnells-MacBook-Pro:Jenkins afinnell$ java -jar jenkins.war
Running from: /Applications/Jenkins/jenkins.war
webroot: $user.home/.jenkins
[Winstone 2011/08/21 12:33:19] - Beginning extraction from war file
Jenkins home directory: /Users/afinnell/.jenkins found at: $user.home/.jenkins
[Winstone 2011/08/21 12:33:21] - HTTP Listener started: port=9494

Upvotes: 17

Related Questions