How to retrieve current workspace using Jenkins Pipeline Groovy script?

后端 未结 7 1181
独厮守ぢ
独厮守ぢ 2020-12-29 20:03

I am trying to get the current workspace of my Jenkins build using a Groovy pipeline script:

node(\'master\') {
    // PULL IN ENVIRONMENT VARIABLES
    // J         


        
7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 20:57

    A quick note for anyone who is using bat in the job and needs to access Workspace:

    It won't work.

    $WORKSPACE https://issues.jenkins-ci.org/browse/JENKINS-33511 as mentioned here only works with PowerShell. So your code should have powershell for execution

     stage('Verifying Workspace') {
      powershell label: '', script: 'dir $WORKSPACE'
    }
    

提交回复
热议问题