如何解决Jenkinsfile Dockerfile绑定卷pwd
Jenkins在docker容器中运行(这可行)。在使用Jenkinsfile的作业中,我试图将卷绑定到Jenkins中的当前工作目录到作业容器中的路径,但是我无法使当前工作目录的值起作用。我已经尝试过env.WORKSPACE和pwd(),但是工作出错了。我应该如何声明 -v $ {pwd):/ workdir 的等效项?以及我如何添加其他卷?
我的 Dockerfile.job 很简单:
FROM crops/poky:ubuntu-18.04
RUN /bin/bash -c 'echo La la la'
ENV myblah="my blah variable" \
otherblah="this is another bla variable"
ADD entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]
让我感到悲伤的 Jenkinsfile 阶段是这样的:
stage('this problematic stage') {
agent {
dockerfile {
filename 'Dockerfile.job'
args "-v ${pwd()}:/workdir" // <- help! this doesn't work
}
}
steps {
// this works fine if I comment out my args above
echo "yoohoo"
sh 'echo myblah = $myblah'
sh 'echo otherblah = $otherblah'
}
好奇的 entrypoint.sh 是JENKINS错误51307的复制粘贴
!/bin/sh
# Workaround script for Jenkins bug: https://issues.jenkins-ci.org/browse/JENKINS-51307
set -e
# check if there was a command passed
# required by Jenkins Docker plugin: https://github.com/docker-library/official-images#consistency
if [ "$1" ]; then
# execute it
exec "$@"
fi
# else run my script
exec ls -la
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。