Reputation: 55271
With this minimal Jenkins Pipeline script
node {
docker.build("foo", "--build-arg x=y")
}
I'm getting a confusing error
"docker build" requires exactly 1 argument(s).
But as per the documentation, the signature of docker.build()
is build(image[, args])
(from 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 http_proxy=http://192.168.1.1:3128 .'
. Like docker build, args must end with the build context. Returns the resulting Image object. Records a FROM fingerprint in the build.
What's going on?
Upvotes: 26
Views: 18718
Reputation: 55271
My confusion was because the error message is actually coming from Docker, not Jenkins.
Docker gives this error if you don't specify a build context (as noted in the docs above).
The fix is just to add .
to the end of the args parameter as per the example, eg:
node {
docker.build("foo", "--build-arg x=y .")
}
See docker: "build" requires 1 argument. See 'docker build --help'
Upvotes: 59