Groovy script not working

1,642 views
Skip to first unread message

Roland Tepp

unread,
Mar 4, 2011, 6:26:21 AM3/4/11
to jenkins...@googlegroups.com
Hi,

I am trying to add Groovy build step to one of my builds and to start it off, I just took the sample script from Groovy Plugin page[1] and pasted it into Groovy Command textbox.

Running the build failed with following message:
[workspace] $ "C:\Program Files\Groovy\Groovy-1.7.8\bin\groovy.exe" "C:\Builds\.jenkins\jobs\ELS - Nightly Build\workspace\hudson7562786651170224702.groovy"
Caught: groovy.lang.MissingPropertyException: No such property: hudson for class: hudson7562786651170224702
at hudson7562786651170224702.run(hudson7562786651170224702.groovy:4)

I copied this script to a separate script in the workspace and tried that way, still the same error:
[workspace] $ "C:\Program Files\Groovy\Groovy-1.7.8\bin\groovy.exe" "C:\Builds\.jenkins\jobs\ELS - Nightly Build\workspace\script.groovy"
Caught: groovy.lang.MissingPropertyException: No such property: hudson for class: script
at script.run(script.groovy:5)
Being new to both Jenkins and Groovy, I have no idea where to start debugging this problem...

[1] http://wiki.hudson-ci.org/pages/viewpage.action?pageId=47087672

Vojtech Juranek

unread,
Mar 4, 2011, 9:42:55 AM3/4/11
to jenkins...@googlegroups.com
Hi,
what did you use, "Execute groovy script" or "Execute system groovy script"? I
guess that "Execute groovy script". Try to run it in "Execute system groovy
script" and it should work fine. In this script you are trying to work with
Jenkins instance itself (hudson.model.Hudson.instance) and therefore you have
to run it in the same JVM as Jenkins (and therefore use "system groovy
script").
Vojtech
Reply all
Reply to author
Forward
0 new messages