TfsTools.Automation

tfs-tools provides cmdlets to mass update build and release definitions. Easy to use in Powershell scripts.


Keywords
tfs, vsts, build, release, queue, variable, repository, branch, export, import, update, automation, script, powershell, automate, mass
Install
Install-Package TfsTools.Automation -Version 1.8.0-prerelease

Documentation

tfs-tools

Some tools for helping working with TFS 2015 on premise or Visual Studio Online.

Builds

If you work with a lot of builds, do some mass update actions on "Build 2015 format" builds.

First, the tool retrieve all build definitions based on a build pattern (ex : build*).

Be careful, if you use some special characters like dot (.), you need to embrace with the following [ and ] characters. For example, if you want to process "prod.*" builds, you need to use the following pattern : "prod[.]*".

For each build definition, you can do these common actions :

  • AddVariable : add a new variable to a build definition
  • Clone : clone a build definition
  • DeleteBuildDefinition : delete a build definition and all related builds
  • Enqueue : enqueue a build definition
  • RemoveVariable : remove variable from build definition
  • UpdateBranch : replace a branch by another one for a build definition
  • UpdateQueue : replace a queue for a build definition
  • UpdateVariable : update variable value for a build definition

Each action generate a timestamped file log prefixed by action name.

Usage samples

  • Cache authentication : Useful when you work with Visual Studio and when you are always connected to TFS.
tfs-tools-builds.exe -Action "{your action}" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -AuthType "cache"
  • PAT authentication : Only for Visual Studio Online. You must use a generated Personal Access Token on your account. See this article for more information :
tfs-tools-builds.exe -Action "{your action}" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -AuthType "pat" -Token="{your token}"
  • Basic authentication : Only for TFS 2015 On-Premise. You set your user name and password. You must previously activate 'Basic authentication' on your IIS hosted TFS. See this article for more information :
tfs-tools-builds.exe -Action "{your action}" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -AuthType "basic" -UserName="{your user name}" -Password="{your password}"
  • AddVariable : For all build definitions matching pattern 'b1.*', add a variable 'v1' with value 'value1'. If variable already exists, the variable is updated with the new value.
tfs-tools-builds.exe -Action "addvariable" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -BuildPattern="b1.*" -VariableName="v1" -VariableValue="value1" -AuthType "pat" -Token="{your token}"
  • Clone : Clone build definitions matching pattern 'b1.*'. All cloned builds are renamed from 'b1.' to 'b2.'
tfs-tools-builds.exe -Action "clone" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -buildpattern="b1.*" -SourceString="b1." -TargetString="b2." -AuthType "pat" -Token="{your token}"
  • DeleteBuildDefinition : Delete build definitions matching pattern 'b1.*'. All associated builds are also deleted.
tfs-tools-builds.exe -Action "deletebuilddefinition" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -buildpattern="b1.*" -AuthType "pat" -Token="{your token}"
  • Enqueue : Enqueue a new build for all build definitions matching pattern 'b1.*'.
tfs-tools-builds.exe -Action "enqueue" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -buildpattern="b1.*" -AuthType "pat" -Token="{your token}"
  • RemoveVariable : For all build definitions matching pattern 'b1.*', remove variable 'v1'. If variable does not exists, the program warns.
tfs-tools-builds.exe -Action "removevariable" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -BuildPattern="b1.*" -VariableName="v1" -AuthType "pat" -Token="{your token}"
  • UpdateBranch : For all build definitions matching pattern 'b1.*', update branch root in triggers and repository sections from '$/test/branch1' to '$/test/branch2'.
tfs-tools-builds.exe -Action "updatebranch" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -BuildPattern="b1.*" -SourceString="$/test/branch1" -TargetString="$/test/branch2" -AuthType "pat" -Token="{your token}"
  • UpdateQueue : For all build definitions matching pattern 'b1.*', update queue to 'Queue1' in General section.
tfs-tools-builds.exe -Action "updatequeue" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -BuildPattern="b1.*" -TargetQueue="Queue1" -AuthType "pat" -Token="{your token}"
  • UpdateVariable : For all build definitions matching pattern 'b1.*', update a variable 'v1' with value 'value1'. If variable does not exists, the program warns.
tfs-tools-builds.exe -Action "updatevariable" -CollectionUri "{your collection uri}" -ProjectName "{your project name}" -BuildPattern="b1.*" -VariableName="v1" -VariableValue="value1" -AuthType "pat" -Token="{your token}"