简体   繁体   English

如何访问 Azure 管道中的环境变量?

[英]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.

相关问题 dockerize create-react-app如何在docker环境下访问azure发布管道变量 - How dockerize create-react-app can access to azure release pipeline variables in docker environment Azure Pipeline Secret 环境变量标记为未定义 - Azure Pipeline Secret environment variables marked as undefined Azure 管道单元测试和环境变量 - Azure Pipeline Unit Tests & Environment Variables 替换 Azure 管道中的 kubernetes yaml 环境变量? - Replace kubernetes yaml environment variables in Azure pipeline? 在 c# 中读取 azure 管道环境变量 - reading azure pipeline environment variables in c# 如何在Azure上的自定义脚本扩展脚本中访问环境变量 - How to access environment variables in custom script extension script on Azure 如何在 ASP.NET 服务器的 web.config 文件中使用 Azure Pipeline 中设置的环境变量? - How to use environment variables set in Azure Pipeline in the web.config file of ASP.NET server? 如何在条件中访问管道变量 - How to access pipeline variables in conditions 如何将特定于环境的值传递给 Azure 管道? - How to pass environment specific values to Azure pipeline? 如何小写 Azure DevOps 管道变量名称 - How to lowercase Azure DevOps pipeline variables names
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM