In scenarios where you have many teams working in the same team project, you might have multiple TFS Git repos within a single team project. When you want to create a build definition for a given repo, you might be wondering what if there is a build definition already exists for the repo. Opening each build definition to find that out is a waste of time. Let’s look at a small utility script that can give you the information quickly using VSTS/TFS REST API.
The PowerShell script I made available here in GitHub and in GitHub gists will help you to generate a quick html report on all repos, build definition information. To use the script you need to have a PAT (Personal Access Token) created with scope of build and code read.
You can call the script as specified below for VSTS.
.\FindBuildsDefsForGivenRepo.ps1 -token 'yourPAT' -collectionUri 'https://youraccount.visualstudio.com' -teamProjectName 'yourteamprojectname' -repoName '*'
for TFS
.\FindBuildsDefsForGivenRepo.ps1 -token 'yourPAT' -collectionUri 'yourTFSProjectCollectionUrl' -teamProjectName 'yourteamprojectname' -repoName '*'
for the repo name parameter below patterns are supported.
- *
- somename*
- *somename*
The script will look for any TFVC repo builds regardless of the repoName parameter value you supply.
It will filter the Git repos in a team project (there can be multiple Git repos in a single team project) using the repoName parameter value and sort the repos by repo name, then will look for build definitions and print them to an html file in the script execution location.
The resultant html file will be created with name RepoBuildDefs.html in the same location of the script and it will list down repos and build definitions, with the clickable links to open the relevant repo or build summary page.
No comments:
Post a Comment