亲爱的#1社区,詹金斯+泊坞窗:如何使用Image.inside命令
我想安装使用泊坞窗图像作为我的构建过程容器一詹金斯CI管道时控制搬运工用户。我正在定义一个Jenkinsfile以将构建管道作为代码。我正在做这样的事情:
node {
docker.withRegistry('http://my.registry.com', 'docker-credentials') {
def buildimage = docker.image('buildimage:latest');
buildimage.pull();
buildimage.inside("")
{
stage('Checkout sources') {
git url: '...', credentialsId: '...'
}
stage('Run Build and Publish') {
sh "..."
}
}
}
}
不幸的是,我在Docker管道插件的奇怪行为上磕磕绊绊。在构建输出我可以看到Image.inside(...)命令触发容器用
docker run -t -d -u 1000:1000 ...
这使得我的生成失败,因为在Dockerfile定义的用户不具有UID 1000。 ..另一个用户实际上被采取。我甚至尝试指定哪些用户应会在Jenkinsfile
node {
docker.withRegistry('http://my.registry.com', 'docker-credentials') {
def buildimage = docker.image('buildimage:latest');
buildimage.pull();
buildimage.inside("-u otheruser:othergroup")
{
stage('Checkout sources') {
git url: '...', credentialsId: '...'
}
stage('Run Build and Publish') {
sh "..."
}
}
}
}
使用,但是这会导致重复-u在所得搬运工运行命令
docker run -t -d -u 1000:1000 -u otheruser:othergroup ...
,显然仅被施加在第一开关-u因为我的构建仍然失败。我也使用whoami进行调试来验证我的假设。
所以我的问题:我该如何改变这种行为?有没有可以将-u 1000:1000关闭的开关?这是一个错误吗?我其实喜欢使用Docker插件,因为它简化了在Jenkins中维护凭据的自己的码头注册表的使用。但是,如果Docker插件不可用,还有另一种简单的方法可以实现我的目标吗?
预先感谢您的宝贵时间
对不起,但这并不回答我的问题。使用-u运行的提示没有帮助,因为它在问题中也没有提到。 – RoK