I\'m trying to publish to Docker from my Jenkins Pipeline but most things I try result in an error. My latest try was this:
docker.withDockerRegistry(\'https
I was able to get around this by installing docker-io on my slave from this Docker image and using a separate Docker host that could service the calls I needed to make to build, run and push my docker image to my registry.
I ended up using the following script to resolve this:
docker.withServer(DOCKER_MACHINE_HOSTNAME) {
def image = docker.build(DOCKER_TAG, '.')
// Test container then stop and remove it
def container = image.run('--name ' + DOCKER_CONTAINER_NAME)
container.stop()
docker.withRegistry(DOCKER_REGISTRY, QUAY_CREDENTIALS_ID ) {
image.push(DOCKER_APPLICATION_TAG)
}
}
This is an ancient question, but I'd like to point out for the benefit of people googling the phrase at the top:
When you get a "Scripts not permitted to use method" error that is specifically about groovy.lang.GroovyObject invokeMethod
, the reason is almost always that you have invoked a method on an object that does not have that method.
In this case, you tried to invoke docker.withDockerRegistry
. There is no method on docker
named withDockerRegistry
.
The method is called simply withRegistry
.
Note that "Scripts not permitted..." errors that are not about GroovyObject invokeMethod
are actual permission issues, but such errors involving GroovyObject invokeMethod
are generally the security system masking a "no such method" error
Maybe it's related to this issue: https://issues.jenkins-ci.org/browse/JENKINS-30414
As explained in the latest comment, The Script Security plugin can be the problem.