7

I am starting my Pipeline this way:

node('my_Label') { // my code }

I want to know in which Slave my code is running. I tried multiple things but I was not able to find out the correct method to call for that :(

Thank you in advance

Leon
  • 255
  • 1
  • 4
  • 11

1 Answers1

9

The environment variable ${NODE_NAME} should have it:

node ('my_Label) {
   println "${NODE_NAME}"
}
Peter McNab
  • 1,031
  • 1
  • 10
  • 11
  • Pipeline has some restrictions on reading env variables (may need to run script outside SandBox or use a Pipeline Library) – Jayan Nov 13 '16 at 05:23
  • Well, it worked fine in my instance running as part of an in-line pipeline script. – Peter McNab Nov 14 '16 at 17:23