Reputation: 1874
I am executing simple groovy script using scriptler jenkins plugin.
import hudson.model.Computer
import hudson.model.Node
println Computer.currentComputer().getNodeName()
If I execute this on master or any slave, giving me NullPointerException
java.lang.NullPointerException: Cannot invoke method getNodeName() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
Not sure what is wrong with script.
Upvotes: 1
Views: 13781
Reputation: 3527
The code you posted can be executed only for specyfic job in "Execute system Groovy script" (it is in your job configuration).
Upvotes: 1
Reputation: 6518
java.lang.NullPointerException: Cannot invoke method getNodeName() on null object
means for Computer.currentComputer().getNodeName()
that Computer.currentComputer()
returns null. As of why that is? There is not enough information to answer this
Upvotes: 0