I'm using a Jenkinsfile to try to push a docker image to my local docker registry in the Jenkins build pipeline plugin. I understand from reading the docs that you should be able to push an image with an optional tagname:
Image.push([tagname])
I've got the following code at the moment
stage('Initialise environment') {
checkout scm
db = docker.build('oracle', 'docker/oracle').run("-p 49160:22 -p 49161:1521")
wlp = docker.build('liberty', 'docker/liberty').run("-p 9080:9080 --link=${db.id}:oracle")
}
stage('Push image to registry') {
docker.withRegistry('https://localhost:5000') {
db.push()
wlp.push()
}
}
It's failing at the first push() with the following error:
Failure: groovy.lang.MissingMethodException: No signature of method: static org.jenkinsci.plugins.docker.workflow.Docker.push() is applicable for argument types: () values: [] Possible solutions: use([Ljava.lang.Object;), use(java.util.List, groovy.lang.Closure), use(java.lang.Class, groovy.lang.Closure), dump(), is(java.lang.Object), each(groovy.lang.Closure)
Any ideas?
Ok, I made the following changes and it appears to have fixed that issue:
dbImage = docker.build('oracle', 'docker/oracle')
db = dbImage.run("-p 49160:22 -p 49161:1521")
wlpImage = docker.build('liberty', 'docker/liberty')
wlp = wlpImage.run("-p 9080:9080 --link=${db.id}:oracle")
}
stage('Push image to registry') {
docker.withRegistry('https://localhost:5000') {
dbImage.push()
wlpImage.push()
}
}
Reading the documentation again I can now see run() returns a handle to the running container, whereas push() can only be called on the image object returned from build()