2

I have sample-job running on node "Windows-prod" node. How can I get the node name using groovy script?

rohitkadam19
  • 1,734
  • 5
  • 21
  • 39

1 Answers1

1

Your question is vague. There are two ways to run groovy scripts.. Groovy plugin on Console which runs groovy (..../script)

The following is for listing node for job using groovy console

def item = hudson.model.Hudson.instance.getItem("createAndPublishSnapshot") 
def build = item.getLastBuild()

println build.isInProgress()
println build.getBuiltOn().getNodeName()
Jayan
  • 18,003
  • 15
  • 89
  • 143
  • I am using scriptler plugin, created one script and using that script in jenkins job. I am able to get build status by using your code but build.getBuiltOn().getNodeName() is returning blank value. – rohitkadam19 Apr 24 '15 at 18:00