加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

哈德森* .groovy在jenkins找不到

发布时间:2020-12-14 16:33:24 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用groovy脚本配置jenkins作业,我不知道我在配置上做错了什么我甚至无法执行简单的groovy命令 println System.getenv("PATH") 当jenkins尝试构建时,它会显示以下堆栈跟踪,然后抛出以下错误 [workspace] $groovy "C:Program Files (x86)Jenkins
我正在尝试使用groovy脚本配置jenkins作业,我不知道我在配置上做错了什么我甚至无法执行简单的groovy命令

println System.getenv("PATH")

当jenkins尝试构建时,它会显示以下堆栈跟踪,然后抛出以下错误

[workspace] $groovy "C:Program Files (x86)Jenkinsjobs{Project_Name}workspacehudson2392295018240496017.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)Jenkinsjobs{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

我在jenkins配置中使用默认的groovy版本,并为groovy安装了jenkins插件.

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

解决方法

你需要安装一个你的Jenkins可以看到的Groovy – 这是默认选项

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

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读