在 Windows 上启动/停止和重启 Jenkins 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14869311/
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:16:17  来源:igfitidea点击:

Start/Stop and Restart Jenkins service on Windows

windowscommand-lineconsolejenkinscommand-prompt

提问by Ripon Al Wasim

I have downloaded "jenkins-1.501.zip" from http://jenkins-ci.org/content/thank-you-downloading-windows-installer.

我已经从http://jenkins-ci.org/content/thank-you-downloading-windows-installer下载了“jenkins-1.501.zip” 。

I have extracted zip file and installed Jenkins on Windows 7 successfully. Jenkins runs at http://localhost:8080/well. I want to stop Jenkins service from console. How can I do that? What's the way to start and restart through console/command line?

我已经解压缩了 zip 文件并成功地在 Windows 7 上安装了 Jenkins。詹金斯跑得http://localhost:8080/很好。我想从控制台停止 Jenkins 服务。我怎样才能做到这一点?通过控制台/命令行启动和重启的方法是什么?

回答by Ripon Al Wasim

Open Console/Command line --> Go to your Jenkins installation directory. Execute the following commands respectively:

打开控制台/命令行 --> 转到您的 Jenkins 安装目录。分别执行以下命令:

to stop:
jenkins.exe stop

停止:
jenkins.exe stop

to start:
jenkins.exe start

开始:
jenkins.exe start

to restart:
jenkins.exe restart

重启:
jenkins.exe restart

回答by Shantonu

To stop JenkinsPlease avoid shutting down the Java process or the Windows service. These are not usual commands. Use those only if your Jenkins is causing problems.

停止 Jenkins请避免关闭 Java 进程或 Windows 服务。这些不是通常的命令。仅当您的 Jenkins 导致问题时才使用这些。

Use Jenkins' way to stop that protects from data loss.

使用 Jenkins 的方式来阻止数据丢失。

http://[jenkins-server]/[command]

where [command] can be any one of the following

其中 [command] 可以是以下任何一项

  • exit
  • restart
  • reload
  • 出口
  • 重新开始
  • 重新加载

Example: if my local PC is running Jenkins at port 8080, it will be

示例:如果我的本地 PC 在端口 8080 上运行 Jenkins,它将是

http://localhost:8080/exit

回答by user108

To start Jenkins from command line

从命令行启动 Jenkins

  1. Open command prompt
  2. Go to the directory where your war file is placed and run the following command:

    java -jar jenkins.war

  1. 打开命令提示符
  2. 转到放置war文件的目录并运行以下命令:

    java -jar jenkins.war

To stop

停止

Ctrl + C

Ctrl + C

回答by Vishwa Deepak Singh

So by default you can open CMD and write

所以默认情况下你可以打开CMD并写入

java -jar jenkins.war

But if your port 8080 is already is in use,so you have to change the Jenkins port number, so for that open Jenkins folder in Program File and open Jenkins.XML file and change the port number such as 8088

但是如果你的 8080 端口已经被使用了,那么你必须更改 Jenkins 端口号,因此在 Program File 中打开 Jenkins 文件夹并打开 Jenkins.XML 文件并更改端口号,例如8088

Now Open CMD and write

现在打开CMD并写入

java -jar jenkins.war --httpPort=8088

回答by Amit Jain

       jenkins.exe stop
       jenkins.exe start
       jenkins.exe restart

These commands will work from cmd only if you run CMD with admin permissions

仅当您使用管理员权限运行 CMD 时,这些命令才能在 cmd 中工作

回答by Roman Denisenko

Small hints for routine work.

日常工作的小提示。

Create a bat file, name it and use for exact run/stop/restart Jenkins service

创建一个 bat 文件,命名并用于精确运行/停止/重启 Jenkins 服务

#!/bin/bash
# go to Jenkins folder
cd C:\Program Files (x86)\Jenkins

#to stop:
jenkins.exe stop

#to start:
#jenkins.exe start

#to restart:
#jenkins.exe restart

回答by Lahiru Amarathunge

Step 01: You need to add jenkins for environment variables, Then you can use jenkins commands

Step 02: Go to "C:\Program Files (x86)\Jenkins"with admin prompt

Step 03: Choose your option: jenkins.exe stop / jenkins.exe start / jenkins.exe restart

步骤01:您需要为环境变量添加jenkins,然后您可以使用jenkins命令

步骤 02:"C:\Program Files (x86)\Jenkins"使用管理员提示转到

步骤 03:选择您的选项: jenkins.exe stop / jenkins.exe start / jenkins.exe restart