rohitkadam19
rohitkadam19

Reputation: 1874

How to get currently running job's node name in jenkins using groovy

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

Upvotes: 2

Views: 8040

Answers (1)

Jayan
Jayan

Reputation: 18459

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()

Upvotes: 1

Related Questions