jenkinsci / kubernetes-cd-plugin

A Jenkins plugin to deploy to Kubernetes cluster
MIT License
140 stars 72 forks source link

Pass variable to yaml #105

Closed ghost closed 4 years ago

ghost commented 4 years ago

Is there any way to pass variables to yaml files such as pass an image tag?

Using something like this image: my-repository/my-image:${env.IMAGE_TAG}

BradNewton commented 4 years ago

It can replace with environment variables, e.g.: image: my-repository/my-image:${IMAGE_TAG}

Then you need to have defined the environmnet variable named IMAGE_TAG. I did this by calling: withEnv(['IMAGE_TAG='+ varName]) { kubernetesDeploy... } (see https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#withenv-set-environment-variables)

ghost commented 4 years ago

Thanks @BradNewton I found another alternative using content replace plugin https://wiki.jenkins.io/display/JENKINS/Content+Replace+Plugin