Pull images from gcr when tag name of the image is constantly changing

6/12/2018

I have made a jenkins pipeline on a kubernetes cluster.

The problem is after pipeline runs, an image is created with a new tag. And because of that i cant hardcode the tag name in the deployment yaml file.

How can i pull the image with the right tag?

-- Yasiru Dinuksha
containers
docker
jenkins
jenkins-pipeline
kubernetes

2 Answers

6/12/2018

I think the correct way to work is to always push the image with a tag and in addition push one tagged latest (which will overwrite the previous latest).

This way inside your kubernetes yaml you can always pull latest.

-- Yonah Dissen
Source: StackOverflow

6/12/2018

Depending upon your given statement and some assumptions, You can try to re-write the Jenkins pipeline to add one more tag:latest.

 stage('Push image') {

    docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
        app.push("${env.BUILD_NUMBER}")
        app.push("latest")
    }

So, I think your yaml will now always pull the latest image. I hope this solves your current problem.

-- papaya
Source: StackOverflow