[英]How to access environment variables in Azure pipeline?
I have created a variable in pipeline as follows,我在管道中创建了一个变量,如下所示,
But I cannot modify or read its value inside pipeline steps.但是我无法在管道步骤中修改或读取它的值。 I tried several formats but it doesn't fetch the value.我尝试了几种格式,但它没有获取值。 What is the correct format of accessing its value?访问其值的正确格式是什么?
Write-Host " bla bla: $($Env:versionnumber)"
Write-Host " bla bla: $($env:versionnumber)"
Write-Host " bla bla: $versionnumber"
Write-Host " bla bla: $($versionnumber)"
它应该是Write-Host "bla bla $env:versionnumber"
Write-Host " bla bla: ($versionnumber)" - 对我有用。
It is mentioned here that Name is upper-cased
, that means we have to use uppercase letters when accessing variables. 这里提到Name is upper-cased
,这意味着我们在访问变量时必须使用大写字母。 I used lower case and it doesn't work.我使用了小写,但它不起作用。
Notice that variables are also made available to scripts through environment variables.请注意,变量也可通过环境变量用于脚本。 The syntax for using these environment variables depends on the scripting language.使用这些环境变量的语法取决于脚本语言。 Name is upper-cased, .名称为大写,. replaced with _, and automatically inserted into the process environment.替换为_,并自动插入到进程环境中。 Here are some examples:这里有些例子:
Batch script: %VARIABLE_NAME% PowerShell script: $env:VARIABLE_NAME Bash script: $VARIABLE_NAME批处理脚本:%VARIABLE_NAME% PowerShell 脚本:$env:VARIABLE_NAME Bash 脚本:$VARIABLE_NAME
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.