2014-09-26 89 views
8

我試圖用Groovy腳本配置詹金斯工作發現,我DONOT知道我在做什麼毛病,我不能執行甚至像哈德森* .groovy作爲不詹金斯

println System.getenv("PATH") 
簡單的常規命令配置

它顯示以下堆棧跟蹤時,詹金斯嘗試構建然後下面的錯誤被拋出

[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的新手。 在此先感謝。

回答

11

你需要有一個安裝了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 
使用
+0

我遵循了上述過程,但我無法構建自己的工作。構建過程需要很長時間。 – RCBian 2015-02-12 12:29:28

+0

Fyi,groovy二進制文件已從codehouse移至bintray,例如:https://bintray.com/artifact/download/groovy/maven/groovy-binary-2.2.1.zip。 – Lidia 2016-03-24 21:21:38

相關問題