windows 在 Jenkins 中运行 bat 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10228327/
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
Running bat files in Jenkins
提问by themaniac27
I have a simple question. I want to run a bat file that should run post build. The bat file takes in to parameters previousVersion and currentVersion (These parameters are entered as Validating String Parameters before the build starts).
我有一个简单的问题。我想运行一个应该运行后期构建的 bat 文件。bat 文件接受参数 previousVersion 和 currentVersion (这些参数在构建开始之前作为验证字符串参数输入)。
This is what I have tried Execute Windows Batch Command
这是我尝试过的 Execute Windows Batch Command
set v = %currentVersion%
set pv = %previousVersion%
cmd \k "C:\jenkins\workspace\mybatfile.bat %pv% %p%"
The error I get is that cmd is not recognized as an internal or external command operable program or batch file exit 9009
我得到的错误是 cmd 未被识别为内部或外部命令可操作程序或批处理文件退出 9009
回答by Jason Swager
Replace "cmd \k" with "call"
将“cmd \k”替换为“call”
The Execute Windows Batch command is running inside a cmd already; no need to specifically start a new one. Just "call" your BAT file.
执行 Windows 批处理命令已经在 cmd 中运行;无需专门开始一个新的。只需“调用”您的 BAT 文件即可。
回答by Fred Xue
if you want to start a separate Command window you can try:
如果你想启动一个单独的命令窗口,你可以尝试:
start cmd \k "your\bat"
here is a reference: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
这是一个参考:http: //www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
回答by Jainish Kapadia
Create file name jenkins.bat
and place this file where your jenkins.war
file is available.
创建文件名jenkins.bat
并将此文件放在您的jenkins.war
文件可用的位置。
You have to click jenkins.bat
file.
您必须单击jenkins.bat
文件。
Note :- After click on jenkins.bat
file, chrome browser will automatically open with jenkins url.
注意:- 点击jenkins.bat
文件后,chrome 浏览器会自动打开 jenkins url。
Try this If your system configured with Java 8 or 7 Installation.
如果您的系统配置了 Java 8 或 7 安装,请尝试此操作。
timeout 3
start chrome http://localhost:8080
timeout 3
java -jar jenkins.war
Try this If your system configured with Java 10 or above Installation.
试试这个 如果您的系统配置了 Java 10 或更高版本 安装。
timeout 3
start chrome http://localhost:8080
timeout 3
java -jar jenkins.war --enable-future-java
回答by Rahul k
I tried to do like this, first point it to the path where your bat file exists, and then 'call' command to trigger that bat file. As below:
我尝试这样做,首先将其指向您的 bat 文件所在的路径,然后使用“调用”命令来触发该 bat 文件。如下:
cd yourFilePath
and then
进而
call yourFile.bat