jenkins使用python plugin编写代码构建时报错:Caused: java.io.IOException: Cannot run program “python“

jenkins的python plugin``编写代码构建时报错:

Building in workspace D:\Jenkins\workspace\pytest项目
[pytest项目] $ python C:\Windows\TEMP\jenkins1719562851337506537.py
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: CreateProcess error=2, 系统找不到指定的文件。
	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 "python" (in directory "D:\Jenkins\workspace\pytest项目"): CreateProcess error=2, 系统找不到指定的文件。
	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:936)
	at hudson.Launcher$ProcStarter.start(Launcher.java:454)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
	at hudson.model.Build$BuildExecution.build(Build.java:206)
	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
	at hudson.model.Run.execute(Run.java:1856)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:428)
Build step 'Execute Python script' marked build as failure
Finished: FAILURE

其中我们看到这一句:
**Caused: java.io.IOException: Cannot run program “python” (in directory “D:\Jenkins\workspace\pytest项目”): CreateProcess error=2, 系统找不到指定的文件。
at java.lang.ProcessBuilder.start(Unknown Source)


大概的意思是python程序没有添加到环境变量中,导致python程序没找到,运行失败`!!``

**

解决办法:把windows本地python的安装路径添加到系统变量的path中,,注意一定要是系统变量的path 如我本地的python安装路径为:C:\Users\admin\AppData\Local\Programs\Python\Python37\

在这里插入图片描述

添加完成后保存,并重启jenkins,再构建一遍

在这里插入图片描述

构建完成

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值