docker 代理选项对共享库无效
docker agent option is invalid for a shared library
当我使用共享库的 运行 管道时,docker 代理的 args
选项无效。
Invalid config option "call" for agent type "docker". Valid config options are [image, alwaysPull, args, containerPerStageRoot, customWorkspace, label, registryCredentialsId, registryUrl, reuseNode] @ line 30, column 25.
args "-u root:root -v ${WORKSPACE}:${goPath}"
^
如果我推荐args
选项,它不会显示这个错误。 image
和 reuseNode
等其他选项按预期工作。
不使用共享库直接在jenkinsfile中使用没有问题
goTest.groovy
def call(){
pipeline{
stage('golang-install') {
agent {
docker {
image 'SOME GOLANG IMAGE'
'args' "-u root:root -v ${WORKSPACE}:${goPath}"
reuseNode true
}
}
...
}
}
}
jenkinsfile 使用共享库
@Library('common-ci') _
goTest()
已解决。因为我将函数参数设置为 args,它会覆盖 args 作为 docker 的选项。更改输入参数名称后,问题解决。
旧的
def call(Map args) {
}
新的
def call(Map opts) {
}
args
选项无效。
Invalid config option "call" for agent type "docker". Valid config options are [image, alwaysPull, args, containerPerStageRoot, customWorkspace, label, registryCredentialsId, registryUrl, reuseNode] @ line 30, column 25.
args "-u root:root -v ${WORKSPACE}:${goPath}"
^
如果我推荐args
选项,它不会显示这个错误。 image
和 reuseNode
等其他选项按预期工作。
不使用共享库直接在jenkinsfile中使用没有问题
goTest.groovy
def call(){
pipeline{
stage('golang-install') {
agent {
docker {
image 'SOME GOLANG IMAGE'
'args' "-u root:root -v ${WORKSPACE}:${goPath}"
reuseNode true
}
}
...
}
}
}
jenkinsfile 使用共享库
@Library('common-ci') _
goTest()
已解决。因为我将函数参数设置为 args,它会覆盖 args 作为 docker 的选项。更改输入参数名称后,问题解决。 旧的
def call(Map args) {
}
新的
def call(Map opts) {
}