[英]Variables from variable group are not recognized in azure devops yaml pipeline
I have a variable group eg 'vargroup' with 3 variables (env ,envid, envpwd) in azure devops.我在 azure devops 中有一个变量组,例如带有 3 个变量(env、envid、envpwd)的“vargroup”。 i have declared the variable group in my yaml definiton too.
我也在我的 yaml 定义中声明了变量组。 If i use inline bash script these variables are being recognized and works fine.
如果我使用内联 bash 脚本,这些变量将被识别并且工作正常。 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) .我的脚本将这些变量称为 $(env) 、 $(envid) 、 $(envpwd) 。
what's the correct way to use the variables from variable group in a script path method?在脚本路径方法中使用变量组中的变量的正确方法是什么?
也许您可以更改脚本以获取参数,然后将变量传递到脚本中:
script.sh $(env) $(envid) $(envpwd)
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.我来自变量组的变量是 env、envid 和 envpwd。 I have passed them as $ENV , $ENVID , $ENVPWD in my shell script and it worked.
我在我的 shell 脚本中将它们作为 $ENV 、 $ENVID 、 $ENVPWD 传递并且它有效。
Note: further to make a secret variable like $ENVPWD to work in azure yaml pipeline you will need to pass it as environment variable注意:要进一步使 $ENVPWD 之类的秘密变量在 azure yaml 管道中工作,您需要将其作为环境变量传递
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.