Unable to change a directory inside a Docker container through a Jenkins declarative pipeline
I had the same problem yesterday. It seems to be a bug that causes dir()
not to change the directory when used inside a container. I've got it to work by executing the cd
and pwd
command at once, like this:
sh '(cd //var/www/html/community-edition && pwd)'
I had same issue and this worked for me when I had "ws" in jenkinsfile pipeline:
stage('prepare') { steps { ws('/var/jenkins_home/workspace/pipeline@script/desiredDir') { sh ''