How about this :
import jenkins.model.* node () { def nodeName = ${env.NODE_NAME} def nodeRootPath = nodeRootDir(nodeName) ... } @NonCPS def nodeRootDir(nodeName) { for (node in Jenkins.instance.nodes) { if ( !nodeName.equals('master') && node.name.equals(nodeName) ) { return node.getRootPath() break } } } On 1/9/17, 9:01 AM, "jenkinsci-users@googlegroups.com on behalf of Kristian" <jenkinsci-users@googlegroups.com on behalf of kristianonlin...@gmail.com> wrote: This gives me the workspace of the job. But I want the root directory which I set when I create a new slave node in Jenkins. So, as an example, I create a new slave node. The root directory i am setting there is /home/jenkins. Currently, when I run a job, I get "/home/jenkins/workspace/Some Job Name" when running pwd(). But I want only this "/home/jenkins" stuff. 2017-01-09 17:54 GMT+01:00 Slide <slide.o....@gmail.com>: > You can use pwd, to get it. > > node() { > ROOT = pwd() > } > > On Mon, Jan 9, 2017 at 9:45 AM Kristian <kristianonlin...@gmail.com> wrote: >> >> Hi, >> >> do someone knows how to get the root directory of a node in a Pipeline >> script? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Jenkins Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to jenkinsci-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jenkinsci-users/CAO5HUhMvCZXGLe91bb4W%3DpHGH470C2QbVF5CX70XdeL0aYm5_A%40mail.gmail.com. >> For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to jenkinsci-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVfJ0UjVfPnQhq8rTsj6Sde9uCUKOopQzJfLRRegLiWE1Q%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO5HUhOBwpNj0aEoB3G_sWYaZAExoakgmSX9udSx7CvQQeCYdw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3E417B6C-4745-4E56-BF49-9DA1E8579708%40cisco.com. For more options, visit https://groups.google.com/d/optout.