我在詹金斯中运行作业时遇到问题。每次,它都找不到不存在的文件。我不知道这是否是詹金斯的问题。反正我没有添加 sh -xe 命令。
> git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
> git.exe rev-parse "refs/remotes/origin/develop^{commit}" # timeout=10
Checking out Revision b899772a479187befd2be7382db2a4bc07953ae1 (refs/remotes/origin/develop)
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f b899772a479187befd2be7382db2a4bc07953ae1 # timeout=10
Commit message: "#14502 poprawa"
> git.exe rev-list --no-walk b899772a479187befd2be7382db2a4bc07953ae1 # timeout=10
[develop] $ sh -xe C:\Windows\TEMP\jenkins1627451732551908110.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: CreateProcess error=2, Nie można odnaleźć określonego pliku
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
Caused: java.io.IOException: Cannot run program "sh" (in directory "C:\inetpub\wwwroot\develop"): CreateProcess error=2, Nie można odnaleźć określonego pliku
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
at hudson.Launcher$ProcStarter.start(Launcher.java:508)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:144)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:92)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
at hudson.model.Build$BuildExecution.build(Build.java:197)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:513)
at hudson.model.Run.execute(Run.java:1908)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Build step 'Uruchom powłokę' marked build as failure
Finished: FAILURE
使用“执行 Windows 批处理命令”而不是“执行 shell”
更改 jenkins 配置中 shell 可执行文件的路径:
登录詹金斯并转到: 仪表板 --> 管理 Jenkins --> 系统
在 Shell 可执行文件框中添加完整路径 C:\Program Files\Git\usr in ash.exe(或您正在使用的任何 bash 可执行文件)