Naeem Sarfraz

Blogging about Enterprise Architecture, ALM, DevOps & happy times coding in .Net

An Alternative Method to Timestamp a File or Folder in Release Management 2013

In a previous post I presented a powershell script to attach a timestamp suffix to files or folders backed up prior to a deployment. At the point of writing that post I wasn’t aware of a collection of runtime variables that are available in your powershell script.

Below is alternate script to the last one I presented. The suffix in this script is not using the current date and time but the $ReleaseId variable which is a number. Each time a new released is created and executed this variable will contain a new value but remember a release maybe re-tried in which case this value will not change. You could also use the $BuildNumber variable (alter line 7) which is the unique Id TFS assigns to the build and is a number.

Runtime Variables in TFS 2015 Build

Following my previous post here is a script which writes out all the TFS 2015 Build variables. These variables are documented here however as you’ll see the names are not quite correct so you should find this script useful.

The end of the script will also dump out all variables (undocumented ones) to the logs too.

Runtime Variables in Release Management

Deploying a vNext release means you can take advantage of global variables in your powershell script. A complete description of what is available and how you can configure your own is available here.

Here is a simple script which I found useful when you simply want to know\confirm the values being pushed to your script. The end of the script will also dump out all variables (undocumented ones) to the logs too.