0

I want to pass variable between release tasks. (from triggered build to script)

Files:

Script1: (saves a env variable)

Write-Output ("##vso[task.setvariable variable=MyVar;]$MyVarValue")

Script2: (prints the env variable value)

Write-host $env:MyVar

Script3: (same as Script2)

Write-host $env:MyVar

First approach: build

  • MyBuild:

    • Script1
    • Script2

This is working properly, the second script writes the value of $env:MyVar created in the first.

Second Approach: release - MyRelease:

  • Script1
  • Script2

Also works properly.

My problem comes when my release changes to:

  • MyRelease:
    • Triggered_build (MyBuild)
    • Script3

In that last case, the Script3 is not printing the $env:MyVar, so I guess that release uses a different environment than the used for the triggered build?

Is there a way to do something like that?

Alezis
  • 1,182
  • 3
  • 13
  • 25
  • What is the information you're trying to pass from build to release? There may be a better way of achieving your desired results. – Daniel Mann Jun 06 '18 at 14:28
  • is a variable calculated when the build is executed, a path – Alezis Jun 07 '18 at 15:49
  • @Ale Xis, Thanks for sharing your solution here, would you please mark your solution as an answer, so it could help other community members. – Jack Zhai Jun 25 '18 at 01:41

1 Answers1

0

No way to do that directly with TFS.

I have read about variable groups, but is not possible to set the variables dynamically in execution time with a script.

The only solution found is using the plugin Variable (de|re)Hydration Tasks

Solution from: Is possible to pass a variable from a Build to a Release in TFS 2017?

Alezis
  • 1,182
  • 3
  • 13
  • 25