Windows上的Hudson-错误:java.io.IOException:无法运行程序;上海";
我正在尝试与Hudson和MSTest进行持续集成 尝试运行此作业时,出现以下错误:Windows上的Hudson-错误:java.io.IOException:无法运行程序;上海";,windows,jenkins,continuous-integration,hudson,Windows,Jenkins,Continuous Integration,Hudson,我正在尝试与Hudson和MSTest进行持续集成 尝试运行此作业时,出现以下错误: 1 Warnung(en) 0 Fehler Verstrichene Zeit 00:00:00.13 [workspace] $ sh -xe C:\Windows\TEMP\hudson4419897732634199534.sh The system cannot find the file specified FATAL: Befehlsausführung fehlgeschlagen j
1 Warnung(en)
0 Fehler
Verstrichene Zeit 00:00:00.13
[workspace] $ sh -xe C:\Windows\TEMP\hudson4419897732634199534.sh
The system cannot find the file specified
FATAL: Befehlsausführung fehlgeschlagen
java.io.IOException: Cannot run program "sh" (in directory "C:\Users\Markus\.hudson\jobs\Test1 Unit TEst\workspace"): CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:187)
at hudson.Proc$LocalProc.<init>(Proc.java:157)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:649)
at hudson.Launcher$ProcStarter.start(Launcher.java:266)
at hudson.Launcher$ProcStarter.join(Launcher.java:273)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:79)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:54)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:34)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:646)
at hudson.model.Build$RunnerImpl.build(Build.java:181)
at hudson.model.Build$RunnerImpl.doRun(Build.java:136)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:434)
at hudson.model.Run.run(Run.java:1390)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:40)
at hudson.model.ResourceController.execute(ResourceController.java:81)
at hudson.model.Executor.run(Executor.java:137)
Caused by: java.io.IOException: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 17 more
Processing tests results in file results.trx
FATAL: No MSTest TRX test report files were found. Configuration error?
[DEBUG] Skipping watched dependency update for build: Test1 Unit TEst #5 due to result: FAILURE
Finished: FAILURE
我的命令行如下所示:
Buildverfahren
Build a Visual Studio project or solution using MSBuild
MSBuild Version MS Build .NET 4
MSBuild Build File trunk\UnitTestWithNHibernate\UnitTestWithNHibernate.sln
Command Line Arguments /p:Configuration=Release
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"
/runconfig: trunk\UnitTestWithNHibernate\UnitTest\LocalTestRun.testrunconfig /testcontainer: trunk\UnitTestWithNHibernate\UnitTest\bin\Debug\UnitTest.dll /resultsfile:results.trx
如果将Windows命令指定为“执行shell”而不是“执行Windows批处理命令”,则会发生这种情况。发生这种情况是因为Jenkins不知道shell路径。
在Manage Jenkins->Configure System->Shell中,将Shell路径设置为 C:\Windows\system32\cmd.exe
在我的例子中,在系统重新启动和迁移之前,构建使用“executeshell”进行工作,并给出了
之后不能运行程序“sh”
。问题是系统路径意外变短。原因不清楚,但路径丢失了C:\ProgramFiles(x86)\Git\bin
,我使用的Git版本附带了sh.exe
当然,您可以按照@funkybro的建议,将所有作业中的“执行shell”构建步骤更改为“执行Windows批处理命令”。如果您有一个作业可以在Windows系统或Linux系统上运行,并且由于其他原因您同时拥有这两个系统,那么这并不能解决您的问题
或者,您可以将此设置更改为使用@ajith:Manage Jenkins->Configure System->Shell->Shell executable=C:\Windows\system32\cmd.exe
但是,我喜欢使用linux命令并使用更像Bash的东西。这是我自己的偏好,但我认为这可能也有帮助。从一开始,我就安装Git。我还建议GnuWin为您提供一些非常有用的Unix命令
- 安装
- 在CMD或PowerShell中:
cinst gnuwin git
C:\ProgramFiles(x86)\Git\bin\
来解决此问题
或者您可以在Jenkins全局配置中修复它:Manage Jenkins->Configure System->Shell->Shell executable=
C:\Program Files(x86)\Git\bin\sh.exe
解决问题的方法是将C:\Windows\system32\cmd.exe
的值放入Hudson系统配置中的“Shell executable”配置中
在作业的“生成”部分中,可以在编译项目后执行windows命令
例:
此问题将通过尝试此命令使jenkins作业运行来解决 对于我来说,只要在manage jenkins-->configure system-->search For shell-->中尝试更新它,并在shell可执行文件中发出以下命令。这很有帮助
C:\Program Files\Git\bin\sh.exe只需使用“windows批处理命令”,并按照您希望在命令行中键入的方式输入windows命令。找到了问题。必须将shell指定为C\windows\system32\cmd.exe请回答您自己的问题,这样将来它可以帮助其他人,所以人们阅读您的整个问题不会只是为了发现问题已经解决。谢谢@Nate。我也有同样的问题。问题是我的git安装只添加了\git\cmd\而不是\git\bin..我还必须重置与节点的连接以使Jenkins重新加载路径。如果我在全局Jenkins配置中指定shell可执行文件,即使我的Linux和OSX从机也会尝试使用它,这会导致它们都失败?!有没有一种方法可以为我的Windows从属程序指定shell可执行路径?这是一个很好的问题,但不幸的是,我不知道答案,我也没有让Jenkins再做实验。我建议您尝试寻找特定于从属服务器的设置或其他解决方案。对不起,我帮不上更多的忙。难道它不应该从
路径
中找出答案吗?您好,我有windows和linux机器作为从机。如果我设置cmd.exe的路径,那么它将停止在linux上工作machines@ajith:我在windows计算机和执行shell命令的作业中将此路径设置为echo“HelloWorld”,但未打印。我得到的结果与@Swift,build success相同,但我认为它没有执行该命令
copy target\pmd-rules-extensions-0.0.1-SNAPSHOT.jar D:\projects\sonar\sonar-3.4.1\extensions\rules\pmd\