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?
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.
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.