I have a pipeline with two stages, the first one pushes a docker image and the second one is supposed to write that image tag in a Kubernetes manifest and apply it. How do I pass the image tag from one stage to another? My pipeline looks like this
image: docker:latest
variables:
DOCKER_DRIVER: overlay
services:
- docker:dind
stages:
- publish_image
- deploy_staging
publish_image:
stage: publish_image
only:
- master
script:- apk add --update git python3 make
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- make canopy
- ./deployment/version.sh
deploy_staging:
image: google/cloud-sdk
stage: deploy_staging
only:
- master
script:- cat ./deployment/canopy.yaml
- echo “$GOOGLE_KEY” > key.json
- gcloud auth activate-service-account --key-file key.json
- gcloud config set project myproject
- gcloud container clusters get-credentials staging-cluster --zone europe-west1-b
- kubectl apply -f ./deployments/canopy.yaml
- kubectl get po
The shell script computes a tag and pushes an image to gitlab docker registry