简体   繁体   中英

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM