Execute groovy script in Masters throwing error

883 views
Skip to first unread message

suchit biswal

unread,
Aug 14, 2014, 3:04:31 PM8/14/14
to jenkins...@googlegroups.com
Hi Folks, 

I am trying to execute the following groovy script as part of my build step, which will get the latest build number for a job and will insert as a env variable of the current job 

Please help me resolving this. 


def item = hudson.model.Hudson.instance.getItem("SDPAutomationExecution")

def build = item.getLastBuild()

println(build.getNumber())

  
def pa = new ParametersAction([
  new StringParameterValue("miniVersion", build.getNumber())
])

// add variable to current job
Thread.currentThread().executable.addAction(pa)


here is the exception 

Execution of script [getLatestBuildNumber.groovy] failed - org.jenkinsci.plugins.scriptler.util.GroovyScript$ScriptlerExecutionException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 8: unable to resolve class ParametersAction 
 @ line 8, column 10.
   def pa = new ParametersAction([
            ^

Script1.groovy: 9: unable to resolve class StringParameterValue 
 @ line 9, column 3.
     new StringParameterValue("miniVersion", build.getNumber())
     ^

2 errors
hudson.remoting.ProxyException: org.jenkinsci.plugins.scriptler.util.GroovyScript$ScriptlerExecutionException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 8: unable to resolve class ParametersAction 
 @ line 8, column 10.
   def pa = new ParametersAction([
            ^

Script1.groovy: 9: unable to resolve class StringParameterValue 
 @ line 9, column 3.
     new StringParameterValue("miniVersion", build.getNumber())
     ^

2 errors

	at org.jenkinsci.plugins.scriptler.util.GroovyScript.call(GroovyScript.java:131)
	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
	at hudson.remoting.Request$2.run(Request.java:328)
	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at hudson.remoting.Engine$1$1.run(Engine.java:63)
	at java.lang.Thread.run(Unknown Source)
Caused by: hudson.remoting.ProxyException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 8: unable to resolve class ParametersAction 

Eric Pyle

unread,
Aug 14, 2014, 5:42:21 PM8/14/14
to Jenkins Users

I think you need to import the classes containing those items that don't resolve. I don't have the doc in front of me so I can't check what class to import

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

suchit biswal

unread,
Aug 15, 2014, 1:50:34 AM8/15/14
to jenkins...@googlegroups.com
yes I imported the packages, and copyied the hudsion-core.jar  to the lip folder in masters resolved the issue
Reply all
Reply to author
Forward
0 new messages