Jenkins pipeline how to change to another folder

前端 未结 3 421
南旧
南旧 2020-12-13 11:49

Currently i am using Jenkins pipeline script.

For running one command, I need to access a folder outside its workspace directory.

I tried sh \"cd $wor

相关标签:
3条回答
  • 2020-12-13 12:21

    You can use the dir step, example:

    dir("folder") {
        sh "pwd"
    }
    

    The folder can be relative or absolute path.

    0 讨论(0)
  • 2020-12-13 12:30

    Use WORKSPACE environment variable to change workspace directory.

    If doing using Jenkinsfile, use following code :

    dir("${env.WORKSPACE}/aQA"){
        sh "pwd"
    }
    
    0 讨论(0)
  • 2020-12-13 12:32

    The dir wrapper can wrap, any other step, and it all works inside a steps block, for example:

            steps {
              sh "pwd"
              dir('your-sub-directory'){
                sh "pwd"
              }
              sh "pwd"
            } 
    
    0 讨论(0)
提交回复
热议问题