我刚接触Jenkins,最近想要安排一个工作来执行本地的Python脚本。由于我还没有源代码控制,因此在创建Jenkins UI中的工作时选择了“无”。
我对如何在Jenkins UI中执行Python脚本进行了一些研究,并尝试使用Python插件将Python脚本作为构建步骤执行。但失败了。(实际上,我不想使用此插件,因为我的脚本需要输入参数,所以我认为我需要在BUILD字段中选择类似于“execute shell”的选项--我尝试过,但也失败了)有谁能帮我找出如何正确运行/调用本地的Python脚本吗?
附注:我也不清楚Jenkins工作空间以及它是如何工作的?如果有人能为我澄清这个问题那就太好了。
以下是我在构建失败后得到的控制台输出:
Started by user Yiming Chen
[EnvInject] - Loading node environment variables.
Building in workspace D:\Application\Jenkins\workspace\downloader
[downloader] $ sh -xe C:\windows\TEMP\hudson3430410121213277597.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "sh" (in directory "D:\Application\Jenkins\workspace\downloader"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:245)
at hudson.Proc$LocalProc.<init>(Proc.java:214)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:846)
at hudson.Launcher$ProcStarter.start(Launcher.java:384)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:108)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:65)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1728)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 16 more
Build step 'Execute shell' marked build as failure
Finished: FAILURE