gmpy1990
gmpy1990

Reputation: 75

Variables from variable group are not recognized in azure devops yaml pipeline

I have a variable group e.g. 'vargroup' with 3 variables (env ,envid, envpwd) in azure devops. i have declared the variable group in my yaml definiton too. If i use inline bash script these variables are being recognized and works fine. However when I use the same script but located in the repository, the script does not recognize the variables in variable group.

variables:
- group: vargroup

- task: Bash@3
  inputs:
    filePath: 'script.sh'

my script calls these variables as $(env) , $(envid) , $(envpwd) .

what's the correct way to use the variables from variable group in a script path method?

Upvotes: 2

Views: 2104

Answers (2)

jedipi
jedipi

Reputation: 175

Maybe you can change your script to take arguments and then pass your variables into your script:

script.sh $(env) $(envid) $(envpwd)

Upvotes: 0

gmpy1990
gmpy1990

Reputation: 75

After multiple tries , finally I have found the solution.

trick: using capital letters for passing the variables in the script.

my variables from variable group are env , envid & envpwd. I have passed them as $ENV , $ENVID , $ENVPWD in my shell script and it worked.

Note: further to make a secret variable like $ENVPWD to work in azure yaml pipeline you will need to pass it as environment variable

Upvotes: 2

Related Questions