openalm / Extension-UtilitiesPack

Release Management utility tasks
Other
34 stars 38 forks source link

Tokenizer: Predefined variables #67

Closed gellmaster closed 7 years ago

gellmaster commented 7 years ago

I’m exploring the Tokenizer task as a way to surface some build information in my web app by updating a couple web.config app settings.

I am trying to use “BUILD_BUILDNUMBER” and “BUILD_SOURCEVERSION” in the web.config. I am not using configuration json. As best as I can tell it seems predefined variables are not included for replacement, only user defined. Is this accurate or am I not doing something correctly?

    <add key="BuildNumber" value="__BUILD_BUILDNUMBER__" />
    <add key="SourceVersion" value="__BUILD_SOURCEVERSION__" />

If predefined variables are not included, please consider this an enhancement request as I could see other reasons to utilize the various predefined variables at build or release time.

Thanks in advance for your help!

Log output from task:

2016-12-29T21:25:50.3561235Z ##[section]Starting: Tokenizer: Transform Source filename 2016-12-29T21:25:50.3640916Z ============================================================================== 2016-12-29T21:25:50.3640916Z Task : Tokenize with XPath/Regular expressions 2016-12-29T21:25:50.3640916Z Description : Replaces and/or XPath for XML documents with User Defined variables or configuration json document 2016-12-29T21:25:50.3640916Z Version : 2.0.2 2016-12-29T21:25:50.3640916Z Author : ms-devlabs 2016-12-29T21:25:50.3640916Z Help : More Information 2016-12-29T21:25:50.3640916Z ============================================================================== 2016-12-29T21:25:53.0814526Z Environment: default 2016-12-29T21:25:55.8564531Z Updating token 'BUILD_BUILDNUMBER' 2016-12-29T21:25:55.8564531Z No value found for token 'BUILD_BUILDNUMBER' 2016-12-29T21:25:55.9114525Z Updating token 'BUILD_SOURCEVERSION' 2016-12-29T21:25:55.9344527Z No value found for token 'BUILD_SOURCEVERSION' 2016-12-29T21:25:55.9574514Z ##[section]Finishing: Tokenizer: Transform Source filename

degant commented 7 years ago

Any update on this? I am also looking to replace using pre-defined variables instead of having to define values in the Configuration Json.

devingoble commented 7 years ago

Try replacing the underscores inside the variable name with periods.

    <add key="BuildDefinition" value="__Build.DefinitionName__"/>
    <add key="FinishTime" value="__Build.BuildNumber__"/>

This is how we use it, and it works fine.

gellmaster commented 7 years ago

Sorry for the delay.

That did the trick! I still haven’t found documentation that clearly highlights this exact format, so thank you @devingoble for taking your time to help.

It seems the “Azure App Service Deploy” v3 task has similar functionality that I may explore. It would be nice to see a build only task, like this extension, that is baked in to VSTS. Extensions require a VSTS admin to install and getting approval slowdowns the process of creating a build definition in a new VSTS environment.