问题
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 ?
回答1:
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.
回答2:
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.
回答3:
Have you tried just passing the variable into the task definition like $(MyVariable)
(where MyVariable is the custom variable name)?
来源:https://stackoverflow.com/questions/43496281/is-possible-to-pass-a-variable-from-a-build-to-a-release-in-tfs-2017