tfsmsbuildworkflow-foundation-4tfsbuildbuild-numbers

Is there a way to "Queue new Build" and override the output created by the Build Number Format


We are running TFS 2013 update 3 with Git - We have a powershell script that uses the output created by the BuildNumberFormat (environment variable TF_BUILD_BUILDNUMBER) that is generated at the time a build is executed. We also want to be able to queue a new build, and override that auto-generated BuildNumber, and specify a alternate (targeted hotfix for a previous tree / branch). With the default build template, there is no option to change the Build Number format (where we can statically set the desired value).

Our Build template: enter image description here

Queue New Build template where we are targeting a specific changeset:

enter image description here

So the question is -- Do I need to edit the build work flow xaml to add this option as something that is passed in or is there a simpler way? I would like not to have to edit my power shell scripts that depend on this if we can. Ideas are greatly appreciated.


Solution

  • I ended up figuring it out, and it was incredibly easy. This may be an answer for similar questions also.

    1. Copy the default build template (you can press download)enter image description here
    2. Place the file in your Repo path such as /BuildProcessTemplates/companyName.GitTemplate.12.xaml
    3. Open the new xaml file in visual studios.
    4. At the bottom of the screen, click the "Arguments" enter image description here
    5. Scroll down to "Metadata" and click on the edit button on the right enter image description here
    6. Scroll down to BuildNumberFormat - select it, and on the drop down "View this parameter when", change it to "Always Show the parameter" enter image description here
    7. Save the template, Commit it to your Git repo, push to your Git server.
    8. Update your build Definition to use your new build template
    9. You can now specify your own BuildNumber enter image description here

    Hope this helps someone. Looks useful for the other variables available in the build template.