Find out in which Slave the Jenkins Pipeline is running
Asked Answered
B

1

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

Ber answered 11/11, 2016 at 16:9 Comment(0)
Q
10

The environment variable ${NODE_NAME} should have it:

node ('my_Label) {
   println "${NODE_NAME}"
}
Quent answered 11/11, 2016 at 18:35 Comment(2)
Pipeline has some restrictions on reading env variables (may need to run script outside SandBox or use a Pipeline Library)Pangermanism
Well, it worked fine in my instance running as part of an in-line pipeline script.Quent

© 2022 - 2024 — McMap. All rights reserved.