0

I have created a variable in pipeline as follows,

enter image description here

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)"
Channa
  • 3,267
  • 7
  • 41
  • 67
  • like you normally would in powershell – 4c74356b41 Jun 13 '19 at 04:35
  • Possible duplicate of [How to read and set DevOps Pipeline variables using Azure PowerShell?](https://stackoverflow.com/questions/55129487/how-to-read-and-set-devops-pipeline-variables-using-azure-powershell) – Andrey Stukalin Jun 13 '19 at 06:36

3 Answers3

0

It should be Write-Host "bla bla $env:versionnumber"

Andrey Stukalin
  • 5,328
  • 2
  • 31
  • 50
0

Write-Host " bla bla: ($versionnumber)" - Works for me.

Livne Rosenblum
  • 196
  • 1
  • 12
-1

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

Channa
  • 3,267
  • 7
  • 41
  • 67
  • PowerShell is not case-sensitive. This is trivially tested: `$env:COMPUTERNAME` and `$env:computername` both return the same value. – Daniel Mann Jun 13 '19 at 13:12
  • No it doesn't, At least in my case. I tried with both ways and it only works with Uppercase. – Channa Jun 14 '19 at 02:32