Reputation: 75
I've been trying to access a subdirectory inside of my Jenkins workspace with unix command : sh "cd ${workspace}/Myfolder"
, however the command does not work. I am using groovy script in Jenkins (Jenkinsfile).
My ${workspace}
directory is: /var/lib/jenkins/workspace/test_sam_single_pipeline
When I execute command: sh "cd ${workspace}/Myfolder"
I use command: sh "pwd"
The output is:
/var/lib/jenkins/workspace/test_sam_single_pipeline
It seems I cannot access "Myfolder" subdirectory by using the "cd" command.
What am I missing?
Upvotes: 1
Views: 4182
Reputation: 2484
in declarative pipeline you can use
dir('MyFolder') {
sh "pwd"
}
or use one shell for all your commands
sh """
cd MyFolder
pwd
"""
or join commands
sh "cd MyFolder && pwd"
Upvotes: 4