Search code examples
bashazureazure-devopskubernetes-helm

Using Vars In Referenced Bash Script In Azure Dev Ops


I created a Helm chart deploy in a Bash task in azure devops. I was using inline with pipeline vars and that worked great but when I move it to a script in source control now the pipeline vars are empty strings. How should I denote vars in my bash script.

Sample Script:

helm upgrade $(deployment_name) $(file_dir)
--set envVars.rabbitmqhost=$(rabbit_host)

Inline all the vars populate with the vars stored in the pipeline but when the script is referenced by file they are ""

I get errors like this deployment_name: command not found

Do vars refrenced in scripts that are not inline need to be denoted in a different way?


Solution

  • To use the ADO vars in sh or ps1 script file, you will need the help of the Arguments which you can find just under Script Path in your bash task definition.

    The whole process is to pass your variables to the sh/ps1 file as paramters, in your script file, receive them and set them as variables in your script file, use them at last.

    Not familiar with bash code, but maybe you can take this ps example as reference.