Get absolute path to workspace directory in Jenkins Pipeline plugin

前端 未结 4 1943
南方客
南方客 2020-12-01 15:21

I\'m currently doing some evaluation on the Jenkins Pipeline plugin (formerly know as Workflow plugin). Reading the documentation I found out that I currently cannot retriev

4条回答
  •  盖世英雄少女心
    2020-12-01 16:08

    Note: this solution works only if the slaves have the same directory structure as the master. pwd() will return the workspace directory on the master due to JENKINS-33511.

    I used to do it using pwd() functionality of pipeline plugin. So, if you need to get a workspace on slave, you may do smth like this:

    node('label'){
        //now you are on slave labeled with 'label'
        def workspace = pwd()
        //${workspace} will now contain an absolute path to job workspace on slave 
    }
    

提交回复
热议问题