I'm trying to change the current directory using the dir command outlined here: https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-dir-code-change-current-directory
I've edited my pipeline to resemble something like this:
pipeline {
agent { dockerfile true }
stages {
stage('Change working directory...') {
steps {
dir('/var/www/html/community-edition') {
sh 'pwd'
}
}
}
}
}
It doesn't change the directory at all but instead tries to create a directory on the host and fails with java.io.IOException: Failed to mkdirs: /var/www/html/community-edition
Using sh cd /var/www/html/community-edition doesn't seem to work either. How do I change the directory in the container? Someone else seems to have had the same issue but had to change his pipeline structure to change the directory and doesn't sound like a reasonable fix. Isn't the step already being invoked in the container? https://issues.jenkins-ci.org/browse/JENKINS-46636