如何在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:19:49  来源:igfitidea点击:

How to start jenkins on different port rather than 8080 using command prompt in Windows?

windowscommand-linejenkinswarcommand-prompt

提问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

Use the following command at command prompt:

在命令提示符下使用以下命令:

java -jar jenkins.war --httpPort=9090

If you want to use https use the following command:

如果要使用 https,请使用以下命令:

java -jar jenkins.war --httpsPort=9090

Details are here

详情在这里

回答by Prasad

Open the jenkins.xmlin the jenkins home folder (usually C:\Program Files (x86)\Jenkins) and change the port number:
httpPort=xxxx
to
httpPort=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 jenkinspackage)

在 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.xmlwith 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 的默认端口。您需要做的就是:

  1. Goto Jenkins folder present in C:\Program Files (x86)
  2. Open a notepad or text pad and run them as administrator and then try opening the jenkins.xml file present in the jenkins folder.
  3. Change the port number as below: <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=9090</arguments>
  4. Click Save.
  1. 转到 C:\Program Files (x86) 中的 Jenkins 文件夹
  2. 打开记事本或文本板并以管理员身份运行它们,然后尝试打开 jenkins 文件夹中的 jenkins.xml 文件。
  3. 更改端口号如下: <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=9090</arguments>
  4. 单击保存。

回答by Younes

For Fedora, RedHat, CentOSand alike, any customization should be done within /etc/sysconfig/jenkinsinstead of /etc/init.d/jenkins. The purpose of the first file is exactly the customization of the second file.

对于FedoraRedHatCentOS和一样,任何定制应该内完成/etc/sysconfig/jenkins的,而不是/etc/init.d/jenkins。第一个文件的目的正是第二个文件的定制。

So, within /etc/sysconfig/jenkins, there is a the JENKINS_PORTvariable that holds the port number on which Jenkins is running.

因此,在 中/etc/sysconfig/jenkins,有一个JENKINS_PORT保存 Jenkins 运行的端口号的变量。