2

A Build definition has a custom variable that can be set when a build is queued.

Is possible to have access to that variable from a Release in the same way that is possible to have access to variables like Build.DefinitionId, Build.DefinitionName, Build.BuildNumber ?

XtianGIS
  • 967
  • 16
  • 39

3 Answers3

4

I've managed to do this with an extension from the TFS marketplace, called 'Variable (de|re)Hydration Tasks', from naked Agility Ltd. This extension provides build- and release tasks with which you basically can save your build variables and restore them in your release. It does this by prefixes, so you can save/restore all default build variables that are prefixed with 'BUILD-', but if you prefix your own variables with i.e. 'ABC_' you can also save them from your build and restore them in your release.

2

A custom build variable couldn't be used in your release definition. Here is an user voice that similar to your problem: https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/14515326-project-level-build-release-variables. You could vote and add comment below.

As a workaround, you could copy those build variables and their values to a Variable groups. Then add the Variable group to your release definition. This is a new feature in TFS 2017 Update1.

Community
  • 1
  • 1
Tingting0929
  • 4,142
  • 1
  • 14
  • 14
-3

Have you tried just passing the variable into the task definition like $(MyVariable) (where MyVariable is the custom variable name)?

Daniel Morritt
  • 1,787
  • 17
  • 25