I have sample-job running on node "Windows-prod" node. How can I get the node name using groovy script?
Asked
Active
Viewed 7,501 times
2
-
Did you find an answer to this? – hiquetj Feb 26 '20 at 20:11
1 Answers
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