Jenkins pipeline how to change to another folder

喜夏-厌秋 提交于 2019-11-30 13:35:34

问题


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 $workspace/", but it returned current workspace folder.

How I can change to root workspace directory and then cd to another folder. Please help.


回答1:


You can use the dir step, example:

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

The folder can be relative or absolute path.




回答2:


Use WORKSPACE environment variable to change workspace directory.

If doing using Jenkinsfile, use following code :

dir("${env.WORKSPACE}/aQA"){
    sh "pwd"
}


来源:https://stackoverflow.com/questions/52372589/jenkins-pipeline-how-to-change-to-another-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!