Tomer Shemesh
Tomer Shemesh

Reputation: 13335

Jenkins/Hudson CLI API get the node that the script is running on using Groovy

I am using the Hudson API in Jenkins written in groovy and i want to get the labels of the current slave that the script is running on. I know i can get the labels that were passed in but that's not what I want. I can get all the slaves using

hudson.model.Hudson.instance.slaves

but how do I know which one I am running on? once I have the node I can change the label using myslave.getAssignedLabels() but getting that node seems to be an issue. any suggestions?

Upvotes: 0

Views: 396

Answers (1)

luka5z
luka5z

Reputation: 7805

Use getAssignedLabels from Node class:

Computer.currentComputer().getNode().getAssignedLabels() 

Upvotes: 1

Related Questions