Is there a way to push a docker image to a registry without doing the part?

Is there a way to push a docker image to a registry, without doing the part?

Context: This is a project built with spring boot using jdk17 and basically the image is being built but we still need to push this to our private registry.

Side note: we only work with scripted pipelines

What you normally do is something similar to this (which we’re already doing in other projects):

    docker.withRegistry('', 'credentials-id') {

        def customImage ="my-image:${env.BUILD_ID}")

        /* Push the container to the custom Registry */

But we don’t need this part"my-image:${env.BUILD_ID}") and cant find a way of doing push() without it. We’re not using Dockerfiles.

Every piece of documentation I’ve found so far uses the part. I’m really running out of ideas and solutions for this.

Thanks in advance!! calls docker build then wraps it in a docker.image() - docker-workflow-plugin/Docker.groovy at d5d2e5c4007f7ea006152542b2bcbe0f1b2b08aa · jenkinsci/docker-workflow-plugin · GitHub

so you could do def image = docker.image(“originalimagename”) // assumes that the image is already on the agent
you might be able do image.pull() or something. I’m just guessing looking at the script

then you can do image.tag(“foobar”) and image.push(“foobar”)

That being said, I find these “helpers” not helpful at all, and would recommend just using cli docker build docker tag docker push etc