Search code examples
powershelltfsrelease-management

Visual Studio Team Foundation Server 2015 release configuration variables not setting


consider the following in my powershell step:

-source "c:\builds\$(Build.BuildNumber).zip"

result is "c:\builds\20171005.1.zip"

If I try and set the following in the configuration tab of my release variables of release like this Name=MyBuildNumber Value=$(Build.BuildNumber)

If I change my poweshell to look like this

-source "c:\builds\$(MyBuildNumber).zip"

result is "c:\builds\$(Build.BuildNumber).zip"

What am I a doing wrong here? I have tried a few different flavours of stored variables all with the same effect. Could really use some advice.

---------AS PER ANDY-MSFT---- I can confirm I am using Version 14.102.25423.0. I installed the variable extension pack.. no difference. The logs show the literal output. I am pretty sure I am using the exact same setup you are. Please check the screenshot of my definition variable and powershell syntax. TFS 2015 setup


Solution

  • What's the exact version of TFS 2015 and the anent version do you use?

    I tested on TFS 2015 Update4 (Version 14.114.26403.0, Agent.Version:1.95.4), everything works as expected.

    So, please check What version of Team Foundation Server do you have, if you are using earlier version, you can try to upgrade to Update4 or later version, then try it again.

    Besides, if you still want to keep your current version, you can use the VSTS Variable Tasks extension: Variable Toolbox to expand the build/release variables. (And the source code here for your reference.)

    When you define a variable in the Variables screen and use other variables as value, they won't be expanded (as you may have expected). Instead the literal text is passed to the tasks in the workflow. Without this little task the following configuration won't work:

    Variable              Value
    Build.DropLocation    \\share\drops\$(Build.DefinitionName)\$(Build.BuildNumber)
    

    By adding the Expand variable(s) task to the top of your workflow, it will take care of the expansion, so any task below it will receive the value you're after.

    PS: The new agent (version 2.x) auto-expands variables now.

    And this similar thread for your reference: TFS 2015 Can build variables access other build variables?


    UPDATE:

    Based on your TFS version, it should be TFS 2015 update3 (You can upgrade to Update4 or later version if that's an option, also upgrade the build Agent accordingly). To check the agent version : Go Manager Server (gear icon) >> AgentPool >> Select a pool >> select an agent >> Switch to Capabilities, you will see the agent version in that page.

    enter image description here