Public/ReleaseNotes/CollectData/Get-ReleaseNotesDataFromTfvc.ps1
function Get-ReleaseNotesDataFromTfvc { <# .SYNOPSIS Gets release notes data from TFVC based project. .PARAMETER CollectionUri Url for project collection on Azure DevOps server instance. Can be ommitted if $CollectionUri was previously accessed via this API. If not specified, $global:AzureDevOpsApi_CollectionUri (set by Set-AzureDevopsVariables) is used. .PARAMETER Project Project name, identifier, full project URI, or object with any one these properties. Can be ommitted if $Project was previously accessed via this API (will be extracted from the $ArtifactUri). If not specified, $global:AzureDevOpsApi_Project (set by Set-AzureDevopsVariables) is used. .PARAMETER DateFrom Starting date for the considered Changesets. .PARAMETER DateTo Ending date for the considered Changesets. .PARAMETER AsOf Gets the Work Items as they were at this date and time. .PARAMETER ByUser User(s) whose Changesets will be used. .PARAMETER TrunkBranch Trunk branch. The $DateFrom and $DateTo will be used to filter the Changesets on this branch. .PARAMETER ReleaseBranch Release branch. All Changesets on this branch will be considered. .PARAMETER ProgressPreference Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by the Write-Progress cmdlet. .PARAMETER TimePeriodWorkItemsFilter Filter to be used on acquired work items. Included are only passing ones. #> [CmdletBinding()] param( [AllowNull()] [AllowEmptyString()] $CollectionUri, [AllowNull()] [AllowEmptyString()] $Project, [Alias('FromDate', 'From')] [Nullable[DateTime]] $DateFrom, [Alias('ToDate', 'To')] [Nullable[DateTime]] $DateTo, [Nullable[DateTime]] $AsOf, $ByUser, $TrunkBranch = 'Trunk', [AllowNull()] [AllowEmptyString()] [string] $ReleaseBranch, [System.Management.Automation.ActionPreference] $ProgressPreference = $PSCmdlet.GetVariableValue('ProgressPreference'), [Alias('TimePeriodFilter')] [scriptblock] $TimePeriodWorkItemsFilter ) # Gather the release notes data from Changesets $data = @{ } # # Get Work Item Id's from Changesets Show-Host -ForegroundColor Magenta -Object 'Gathering WorkItemRefs from Changesets' $workItemRefs = @( Get-WorkItemRefsListByChangeset ` -CollectionUri $CollectionUri ` -Project $Project ` -DateFrom $DateFrom ` -DateTo $DateTo ` -Branch $TrunkBranch ` -CreatedBy $ByUser ) # Gather the release notes data from Changesets Show-Host -ForegroundColor Magenta -Object 'Gathering Work Item Data from Changesets...' $null = Add-WorkItemToReleaseNotesData ` -CollectionUri $CollectionUri ` -Project $Project ` -ReleaseNotesData $data ` -Reason 'Changeset' ` -AsOf $AsOf ` -WorkItem $workItemRefs # Get Work Item Id's from HotFixes # We want all the hotfixes, so no DateFrom or DateTo if (!$ReleaseBranch) { Show-Host -ForegroundColor Magenta -Object 'Skipping HotFixes...' Show-Host 'Because no Release Branch was specified.' } else { Show-Host -ForegroundColor Magenta -Object 'Gathering HotFixes...' $workItemRefs = @( Get-WorkItemRefsListByChangeset ` -CollectionUri $CollectionUri ` -Project $Project ` -Branch $ReleaseBranch ` -CreatedBy $ByUser ) # Gather the release notes data from HotFixes Show-Host -ForegroundColor Magenta -Object 'Gathering Work Item Data from HotFixes...' $null = Add-WorkItemToReleaseNotesData ` -CollectionUri $CollectionUri ` -Project $Project ` -ReleaseNotesData $data ` -Reason 'HotFix' ` -AsOf $AsOf ` -WorkItem $workItemRefs } # Get Work Item Id's from Time Period Show-Host -ForegroundColor Magenta -Object 'Gathering Time Period Work Items...' $workItemRefs = @( Get-WorkItemRefsListByTimePeriod ` -CollectionUri $CollectionUri ` -Project $Project ` -DateFrom $DateFrom ` -DateTo $DateTo ` -AsOf $AsOf ` -DateAttribute 'Microsoft.VSTS.Common.StateChangeDate' ) # Gather the release notes data from Time Period Show-Host -ForegroundColor Magenta -Object 'Gathering Work Item Data from Time Period...' $null = Add-WorkItemToReleaseNotesData ` -CollectionUri $CollectionUri ` -Project $Project ` -ReleaseNotesData $data ` -Reason 'TimePeriod' ` -AsOf $AsOf ` -WorkItem $workItemRefs ` -Filter $TimePeriodWorkItemsFilter return $data } |