问题描述
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 (将#修改为@)