0

I'm looking for something that would let me know if a new folder has been added directly under my branch in TFVC. I tried using the tf client but though I can fetch the changesets and get history but I couldn't find what I was looking for.

What I want is, suppose there is a TFS branch TestBranch my script will poll that branch at regular intervals and return the folder name if a new folder has been added under that branch directly (sub-folders should be ignored).

Is there any tf command for this ? or how should I try to achieve my desired result?

Note : We are using TFS 2015. Also I tried looking into TFS service hooks so I don't have to poll the branch but creating service hooks requires administrator access which I don't have.

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
boredDev
  • 317
  • 3
  • 18
  • What goal are you looking to accomplish by doing that? – Daniel Mann Jan 30 '18 at 21:57
  • @DanielMann Our projects are structured such as any folder directly checked in under a TFS branch is a project. Jenkins is used to automatically build and deploy the projects. The issue is for every new project added to the TFS branch I have to manually create a job in Jenkins for that. I wanted a script to check if a folder has been added to TFS and create the jenkins job automatically using Jenkins Job DSL. – boredDev Jan 31 '18 at 12:09

1 Answers1

0

No such a built-in trigger to achieve that.

However you can try list the folders under the specific branch directory (local workspace, you need to get latest version first every time) and output the list to a text file, then compare the text files and output the differents periodically/timely as needed based on your requirements.

You can try below PowerShell script sample to achieve that: (The first time to run the script will report the error such as "get-content : Could not find a part of the path 'C:\LC\temp\'", just ignore it. It will works from the second time.)


#Create a folder to store the output text files first, "C:\LC\temp" for example here.
$TempFolder = "C:\LC\temp"

$LocalBranchFolder = "C:\Workspaces\0418Scrum\WorkItemComments" #the path of the branch in local workspace.

$filename = (Get-Date).ToString("yyyyMMdd-HHmmss") + "_" + "FolderList"

$OldFileName = Get-ChildItem -Path $TempFolder | Select-Object -Last 1
$OldFile = "$TempFolder\$OldFileName" 
$NewFile = "$TempFolder\$filename.txt"

write-host $OldFile

#List all the folders under the specific branch (branch folder in local workspace)
Get-ChildItem -Path $LocalBranchFolder –Directory  | Out-File -FilePath $NewFile -Width 200

#Compare the folder lists and output the differents (New added folder)
compare-object (get-content $OldFile) (get-content $NewFile) | format-list

enter image description here

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55