使用这个最小的Jenkins管道脚本
node {
docker.build("foo","--build-arg x=y")
}
我遇到了一个令人困惑的错误
“docker build” requires exactly 1 argument(s).
但根据文档,docker.build()的签名是build(image [,args])(来自Jenkins / job / dockerbug / pipeline-Syntax / globals#docker)
build(image[,args])
Runs docker build to create and tag the specified
image from a Dockerfile in the current directory. Additional args may
be added,such as'-f Dockerfile.other --pull --build-arg
. Like docker build,args must
http_proxy=http://192.168.1.1:3128 .'
end with the build context. Returns the resulting Image object.
Records a FROM fingerprint in the build.
这是怎么回事?
最佳答案
我的困惑是因为错误信息实际上来自Docker,而不是Jenkins.
如果您未指定构建上下文,则Docker会出现此错误(如上文中所述).
修复只是添加.根据示例到args参数的末尾,例如:
node {
docker.build("foo","--build-arg x=y .")
}
见docker: “build” requires 1 argument. See ‘docker build –help’