如何在 Windows 中使用命令提示符在不同的端口而不是 8080 上启动 jenkins?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15265277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to start jenkins on different port rather than 8080 using command prompt in Windows?
提问by Ripon Al Wasim
I have jenkins.war and I started it from command prompt in Windows as:
我有 jenkins.war,我从 Windows 中的命令提示符启动它:
java -jar jenkins.war
It was started well and easily browsed as http://localhost:8080
它开始得很好,很容易浏览 http://localhost:8080
I want to start on 9090 port. How can I do that?
我想从 9090 端口开始。我怎样才能做到这一点?
回答by Ripon Al Wasim
回答by Prasad
Open the jenkins.xml
in the jenkins home folder (usually C:\Program Files (x86)\Jenkins
) and change the port number:httpPort=xxxx
tohttpPort=yyyy
then restart the service. it should change the setting permanently.
打开jenkins.xml
在詹金斯主文件夹(通常C:\Program Files (x86)\Jenkins
),并更改端口号:httpPort=xxxx
到httpPort=yyyy
然后重新启动该服务。它应该永久更改设置。
回答by christian
With Ubuntu 14.4I had to change the file /etc/default/jenkins
使用Ubuntu 14.4我不得不更改文件/etc/default/jenkins
E.g.
例如
#HTTP_PORT=8080
HTTP_PORT=8083
and restart the service
并重启服务
service jenkins restart
service jenkins restart
回答by kanibalv
In CentOS/RedHat (assuming you installed the jenkins
package)
在 CentOS/RedHat 中(假设您安装了该jenkins
软件包)
vim /etc/sysconfig/jenkins
vim /etc/sysconfig/jenkins
....
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8080"
change it to any port you want.
将其更改为您想要的任何端口。
回答by sgrillon
On Windows (with Windows Service).
在 Windows 上(使用 Windows 服务)。
Edit the file C:\Program Files (x86)\Jenkins\jenkins.xml
with 8083if you want 8083 port.
如果需要 8083 端口,请C:\Program Files (x86)\Jenkins\jenkins.xml
使用8083编辑文件。
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8083</arguments>
回答by djb
For the benefit of Linux users who find themselves here: I found /etc/sysconfig/jenkins has a JENKINS_PORT="8080", which you should probably change too.
为了在这里找到自己的 Linux 用户的利益:我发现 /etc/sysconfig/jenkins 有一个 JENKINS_PORT="8080",你也应该改变它。
回答by Jin Thakur
In *nix In CentOS/RedHat
在 *nix 在 CentOS/RedHat
vim /etc/sysconfig/jenkins
vim /etc/sysconfig/jenkins
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8080"
In windows open XML file C:\Program Files (x86)\Jenkins\jenkins.xml
在 Windows 中打开 XML 文件 C:\Program Files (x86)\Jenkins\jenkins.xml
<executable>%BASE%\jre\bin\java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --**httpPort=8083**</arguments>
i made above bold to show you change then
<executable>%BASE%\jre\bin\java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8083</arguments>
now you have to restart it doesnot work unless you restart http://localhost:8080/restartthen after restart http://localhost:8083/all should be well so looks like the all above response which says it does not work We have restart.
现在你必须重新启动它不起作用,除非你重新启动 http://localhost:8080/restart然后重启 http://localhost:8083/ 后一切都应该很好,所以看起来像上面所有的响应,它说它不起作用 我们有重新开始。
回答by mainframer
Correct, use --httpPort parameter. If you also want to specify the $JENKINS_HOME, you can do like this:
正确,使用 --httpPort 参数。如果您还想指定 $JENKINS_HOME,您可以这样做:
java -DJENKINS_HOME=/Users/Heros/jenkins -jar jenkins.war --httpPort=8484
回答by Vinodh Aj
To change the default port of 8080. All you need to do:
要更改 8080 的默认端口。您需要做的就是:
- Goto Jenkins folder present in C:\Program Files (x86)
- Open a notepad or text pad and run them as administrator and then try opening the jenkins.xml file present in the jenkins folder.
- Change the port number as below:
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=9090</arguments>
- Click Save.
- 转到 C:\Program Files (x86) 中的 Jenkins 文件夹
- 打开记事本或文本板并以管理员身份运行它们,然后尝试打开 jenkins 文件夹中的 jenkins.xml 文件。
- 更改端口号如下:
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=9090</arguments>
- 单击保存。
回答by Younes
For Fedora
, RedHat
, CentOS
and alike, any customization should be done within /etc/sysconfig/jenkins
instead of /etc/init.d/jenkins
. The purpose of the first file is exactly the customization of the second file.
对于Fedora
,RedHat
,CentOS
和一样,任何定制应该内完成/etc/sysconfig/jenkins
的,而不是/etc/init.d/jenkins
。第一个文件的目的正是第二个文件的定制。
So, within /etc/sysconfig/jenkins
, there is a the JENKINS_PORT
variable that holds the port number on which Jenkins is running.
因此,在 中/etc/sysconfig/jenkins
,有一个JENKINS_PORT
保存 Jenkins 运行的端口号的变量。