gpt4 book ai didi

groovy - jenkins 中找不到 hudson*.groovy

转载 作者:行者123 更新时间:2023-12-04 00:44:17 24 4
gpt4 key购买 nike

我正在尝试使用 groovy 脚本配置 jenkins 作业,我不知道我在配置上做错了什么,我什至无法执行像这样的简单 groovy 命令

println System.getenv("PATH")

当 jenkins 尝试构建然后抛出以下错误时,它显示以下堆栈跟踪
[workspace] $ groovy "C:\Program Files (x86)\Jenkins\jobs\{Project_Name}\workspace\hudson2392295018240496017.groovy" 
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "groovy" (in directory "C:\Program Files (x86)\Jenkins\jobs\{Project_Name}\workspace"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:780)
at hudson.Launcher$ProcStarter.start(Launcher.java:360)
at hudson.Launcher$ProcStarter.join(Launcher.java:367)
at hudson.plugins.groovy.Groovy.perform(Groovy.java:110)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:535)
at hudson.model.Run.execute(Run.java:1732)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
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 Groovy script' marked build as failure
Finished: FAILURE

我使用的是默认 groovy version在 jenkins 配置中,并为 groovy 安装了 jenkins 插件。

我是 jenkins 和 groovy 的新手。
提前致谢。

最佳答案

您需要安装 Jenkins 可以看到的 Groovy - 这是默认选项

或者,您可以在全局配置中添加一个

enter image description here

然后可以在构建步骤中使用

enter image description here

Started by user anonymous
Building in workspace /Users/xxxxxx/.jenkins/jobs/gr/workspace
[workspace] $ groovy /Users/xxxxx/.jenkins/jobs/gr/workspace/hudson5419917819864291744.groovy
build
/Users/xxxxxx/perl5/perlbrew/bin:/Users/xxxxx/perl5/perlbrew/perls/perl-5.16.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Finished: SUCCESS

关于groovy - jenkins 中找不到 hudson*.groovy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26060521/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com