-4

we have used the env:msg merge but it did take the default value in variables tab. We were unable to assign a value.Even though we see the value in the previous step

enter image description here

The code that assigns the value

$env:msgmerge = 'Git Merge to Master After Deployment Repo:' + "$(reponame)"
Write-Output $env:msgmerge

Environment variables created with $env: are Process variables, so they're lost when the process exits and we can't access them from another process (PowerShell instance).

Rıfat Erdem Sahin
  • 1,738
  • 4
  • 29
  • 47

1 Answers1

2

Ahh this solved we need to use the vsts method

$msgmerge = 'Git Merge to Master After Deployment Repo:' + "$(reponame)"
Write-Output $msgmerge

Write-Host ("##vso[task.setvariable variable=msgmerge;]$msgmerge")
Rıfat Erdem Sahin
  • 1,738
  • 4
  • 29
  • 47
  • What's the point of using `Write-Host`? Your problem was with environment variables. – Maximilian Burszley Dec 04 '17 at 15:35
  • 1
    Even then, why are you using `Write-Host` and not `Write-Output`? At least `Write-Output` would let you do something with what is returned. – Bryce McDonald Dec 04 '17 at 15:40
  • 1
    Seems you want to set new value for the environment variable. And use the new value for the task group (after PowerShell task). So you do should use `Write-Host "##vso[task.setvariable variable=variablename]value"`.You can also refer the powershell script in the document https://learn.microsoft.com/en-us/vsts/build-release/concepts/definitions/release/variables?tabs=powershell#custom-variables. – Marina Liu Dec 05 '17 at 02:29