【发布时间】:2026-02-11 16:05:02
【问题描述】:
我正在尝试使用此处概述的dir 命令更改当前目录:https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-dir-code-change-current-directory
我已将我的管道编辑为类似于以下内容:
pipeline {
agent { dockerfile true }
stages {
stage('Change working directory...') {
steps {
dir('/var/www/html/community-edition') {
sh 'pwd'
}
}
}
}
}
它根本不会更改目录,而是尝试在主机上创建目录并失败并显示java.io.IOException: Failed to mkdirs: /var/www/html/community-edition
使用sh cd /var/www/html/community-edition 似乎也不起作用。如何更改容器中的目录?其他人似乎也有同样的问题,但不得不改变他的管道结构来改变目录,这听起来不像是一个合理的修复。容器中不是已经调用了该步骤吗? https://issues.jenkins-ci.org/browse/JENKINS-46636
【问题讨论】:
标签: docker jenkins jenkins-pipeline