From de7194c7417a7f18ac07375b6d5d350fc0db6770 Mon Sep 17 00:00:00 2001 From: Paul Ballard Date: Wed, 16 Jan 2019 22:55:44 -0600 Subject: [PATCH 1/6] Adding Process Template Support --- .docs/Add-VSTeamProject.md | 14 ++- .docs/Get-VSTeamProcess.md | 81 +++++++++++++ .docs/params/processName.md | 12 ++ .docs/synopsis/Get-VSTeamProcess.md | 1 + VSTeam.psd1 | 3 + src/common.ps1 | 108 ++++++++++++++++++ src/processes.psm1 | 75 ++++++++++++ src/projects.psm1 | 63 +++++----- src/teamspsdrive.ps1 | 55 +++++++++ .../mocks/mockProcessNameDynamicParam.ps1 | 53 +++++++++ unit/test/processes.Tests.ps1 | 107 +++++++++++++++++ 11 files changed, 535 insertions(+), 37 deletions(-) create mode 100644 .docs/Get-VSTeamProcess.md create mode 100644 .docs/params/processName.md create mode 100644 .docs/synopsis/Get-VSTeamProcess.md create mode 100644 src/processes.psm1 create mode 100644 unit/test/mocks/mockProcessNameDynamicParam.ps1 create mode 100644 unit/test/processes.Tests.ps1 diff --git a/.docs/Add-VSTeamProject.md b/.docs/Add-VSTeamProject.md index 5270a2422..19f615bd1 100644 --- a/.docs/Add-VSTeamProject.md +++ b/.docs/Add-VSTeamProject.md @@ -47,15 +47,15 @@ Position: 0 ### -ProcessTemplate -The name of the process template to use for the project. The acceptable values for this parameter are: +The name of the process template to use for the project. -- Agile -- Scrum -- CMMI +You can tab complete from a list of available projects. + +Will use the default process template if one is not provided ```yaml Type: String -Default value: Scrum +Default value: [Determined by Default Process Template definition] ``` ### -Description @@ -84,4 +84,6 @@ Type: SwitchParameter [Add-VSTeamAccount](Add-VSTeamAccount.md) -[Remove-VSTeamProject](Remove-VSTeamProject.md) \ No newline at end of file +[Remove-VSTeamProject](Remove-VSTeamProject.md) + +[Get-VSTeamProcess](Get-VSTeamProcess.md) \ No newline at end of file diff --git a/.docs/Get-VSTeamProcess.md b/.docs/Get-VSTeamProcess.md new file mode 100644 index 000000000..e2f0ab4e9 --- /dev/null +++ b/.docs/Get-VSTeamProcess.md @@ -0,0 +1,81 @@ + + +# Get-VSTeamProcess + +## SYNOPSIS + + + +## SYNTAX + +## DESCRIPTION + +The list of Processs Templates returned can be controlled by using the top and skip parameters. + +You can also get a single Process Template by name or id. + +You must call Add-VSTeamAccount before calling this function. + +## EXAMPLES + +### -------------------------- EXAMPLE 1 -------------------------- + +```PowerShell +PS C:\> Get-VSTeamProcess +``` + +This will return all the Process Templates + +### -------------------------- EXAMPLE 2 -------------------------- + +```PowerShell +PS C:\> Get-VSTeamProcess -top 5 | Format-Wide +``` + +This will return the top five Process Templates only showing their name + +## PARAMETERS + + + +### -Top + +Specifies the maximum number to return. + +```yaml +Type: Int32 +Parameter Sets: List +Default value: 100 +``` + +### -Skip + +Defines the number of Processs Templates to skip. The default value is 0 + +```yaml +Type: Int32 +Parameter Sets: List +Default value: 0 +``` + +### -Id + +The id of the Process Template to return. + +```yaml +Type: String +Parameter Sets: ByID +Aliases: ProcessID +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Add-VSTeamAccount](Add-VSTeamAccount.md) + +[Add-VSTeamProject](Add-VSTeamProject.md) \ No newline at end of file diff --git a/.docs/params/processName.md b/.docs/params/processName.md new file mode 100644 index 000000000..75e67b815 --- /dev/null +++ b/.docs/params/processName.md @@ -0,0 +1,12 @@ +### -Name + +Specifies the process template name for which this function operates. + +You can tab complete from a list of available process templates. + +```yaml +Type: String +Required: true +Position: 0 +Accept pipeline input: true (ByPropertyName) +``` \ No newline at end of file diff --git a/.docs/synopsis/Get-VSTeamProcess.md b/.docs/synopsis/Get-VSTeamProcess.md new file mode 100644 index 000000000..a1ca06e6e --- /dev/null +++ b/.docs/synopsis/Get-VSTeamProcess.md @@ -0,0 +1 @@ +Returns a list of process templates in the Team Services or Team Foundation Server account. \ No newline at end of file diff --git a/VSTeam.psd1 b/VSTeam.psd1 index b936aee59..39c548fa9 100644 --- a/VSTeam.psd1 +++ b/VSTeam.psd1 @@ -102,6 +102,7 @@ 'src\policies.psm1', 'src\policyTypes.psm1' 'src\pools.psm1', + 'src\processes.psm1' 'src\projects.psm1', 'src\queues.psm1', 'src\releaseDefinitions.psm1', @@ -142,6 +143,7 @@ 'Get-VSTeamPolicy', 'Get-VSTeamPolicyType', 'Get-VSTeamPool', + 'Get-VSTeamProcess', 'Get-VSTeamProject', 'Get-VSTeamQueue', 'Get-VSTeamRelease', @@ -266,6 +268,7 @@ 'Add-GitRepository', 'Remove-GitRepository', 'Get-Pool', + 'Get-Process', 'Get-Project', 'Show-Project', 'Update-Project', diff --git a/src/common.ps1 b/src/common.ps1 index ef34164eb..a902fbe76 100644 --- a/src/common.ps1 +++ b/src/common.ps1 @@ -347,6 +347,114 @@ function _buildProjectNameDynamicParam { #> } +function _getProcesses { + if (-not [VSTeamVersions]::Account) { + Write-Output @() + return + } + + $resource = "/process/processes" + $instance = [VSTeamVersions]::Account + $version = [VSTeamVersions]::Core + + # Build the url to list the projects + # You CANNOT use _buildRequestURI here or you will end up + # in an infinite loop. + $listurl = $instance + '/_apis' + $resource + '?api-version=' + $version + '&stateFilter=All&$top=9999' + + # Call the REST API + try { + $resp = _callAPI -url $listurl + + if ($resp.count -gt 0) { + Write-Output ($resp.value).name + } + } + catch { + Write-Output @() + } +} +function _buildProcessNameDynamicParam { + param( + [string] $ParameterName = 'ProcessName', + [string] $ParameterSetName, + [bool] $Mandatory = $true, + [string] $AliasName, + [int] $Position = 0 + ) + + # Create the dictionary + $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary + + # Create the collection of attributes + $AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute] + + # Create and set the parameters' attributes + $ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute + $ParameterAttribute.Mandatory = $Mandatory + $ParameterAttribute.Position = $Position + + if ($ParameterSetName) { + $ParameterAttribute.ParameterSetName = $ParameterSetName + } + + $ParameterAttribute.ValueFromPipelineByPropertyName = $true + $ParameterAttribute.HelpMessage = "The name of the process. You can tab complete from the processes in your Team Services or TFS account when passed on the command line." + + # Add the attributes to the attributes collection + $AttributeCollection.Add($ParameterAttribute) + + if ($AliasName) { + $AliasAttribute = New-Object System.Management.Automation.AliasAttribute(@($AliasName)) + $AttributeCollection.Add($AliasAttribute) + } + + # Generate and set the ValidateSet + if($([VSTeamProcessCache]::timestamp) -ne (Get-Date).Minute) { + $arrSet = _getProcesses + [VSTeamProcessCache]::processes = $arrSet + [VSTeamProcessCache]::timestamp = (Get-Date).Minute + } + else { + $arrSet = [VSTeamProcessCache]::projects + } + + if ($arrSet) { + Write-Verbose "arrSet = $arrSet" + + $ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($arrSet) + + # Add the ValidateSet to the attributes collection + $AttributeCollection.Add($ValidateSetAttribute) + } + + # Create and return the dynamic parameter + $RuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($ParameterName, [string], $AttributeCollection) + $RuntimeParameterDictionary.Add($ParameterName, $RuntimeParameter) + return $RuntimeParameterDictionary + + <# + Builds a dynamic parameter that can be used to tab complete the ProjectName + parameter of functions from a list of projects from the added TFS Account. + You must call Add-VSTeamAccount before trying to use any function that relies + on this dynamic parameter or you will get an error. + + This can only be used in Advanced Fucntion with the [CmdletBinding()] attribute. + The function must also have a begin block that maps the value to a common variable + like this. + + DynamicParam { + # Generate and set the ValidateSet + $arrSet = Get-VSTeamProjects | Select-Object -ExpandProperty Name + + _buildProjectNameDynamicParam -arrSet $arrSet + } + process { + # Bind the parameter to a friendly variable + $ProjectName = $PSBoundParameters[$ParameterName] + } + #> +} function _buildDynamicParam { param( [string] $ParameterName = 'QueueName', diff --git a/src/processes.psm1 b/src/processes.psm1 new file mode 100644 index 000000000..f77a9ffbb --- /dev/null +++ b/src/processes.psm1 @@ -0,0 +1,75 @@ +Set-StrictMode -Version Latest + +# Load common code +$here = Split-Path -Parent $MyInvocation.MyCommand.Path +. "$here\common.ps1" + +function Get-VSTeamProcess { + [CmdletBinding(DefaultParameterSetName = 'List')] + param( + [Parameter(ParameterSetName = 'List')] + [int] $Top = 100, + + [Parameter(ParameterSetName = 'List')] + [int] $Skip = 0, + + [Parameter(ParameterSetName = 'ByID')] + [Alias('ProcessTemplateID')] + [string] $Id + ) + + DynamicParam { + [VSTeamProcessCache]::timestamp = -1 + + _buildProcessNameDynamicParam -ParameterSetName 'ByName' -ParameterName 'Name' + } + + process { + # Bind the parameter to a friendly variable + $ProcessName = $PSBoundParameters["Name"] + + if ($id) { + $queryString = @{} + + # Call the REST API + $resp = _callAPI -Area 'process/processes' -id $id ` + -Version $([VSTeamVersions]::Core) ` + -QueryString $queryString + + $project = [VSTeamProcess]::new($resp) + + Write-Output $project + } + elseif ($ProcessName) { + #Lookup Process ID by Name + Get-VSTeamProcess | where-object {$_.name -eq $ProcessName} + + } + else { + #return list of processes + try { + # Call the REST API + $resp = _callAPI -Area 'process/processes' ` + -Version $([VSTeamVersions]::Core) ` + -QueryString @{ + '$top' = $top + '$skip' = $skip + } + + $objs = @() + + foreach ($item in $resp.value) { + $objs += [VSTeamProcess]::new($item) + } + + Write-Output $objs + } + catch { + # I catch because using -ErrorAction Stop on the Invoke-RestMethod + # was still running the foreach after and reporting useless errors. + # This casuses the first error to terminate this execution. + _handleException $_ + } + } + } +} diff --git a/src/projects.psm1 b/src/projects.psm1 index 88892c111..662629140 100644 --- a/src/projects.psm1 +++ b/src/projects.psm1 @@ -211,50 +211,51 @@ function Add-VSTeamProject { [Alias('Name')] [string] $ProjectName, - [ValidateSet('Agile', 'CMMI', 'Scrum')] - [string] $ProcessTemplate = 'Scrum', - [string] $Description, [switch] $TFVC ) - $srcCtrl = 'Git' - $templateTypeId = '' + DynamicParam { + [VSTeamProcessCache]::timestamp = -1 - switch ($ProcessTemplate) { - 'Agile' { - $templateTypeId = 'adcc42ab-9882-485e-a3ed-7678f01f66bc' - } - 'CMMI' { - $templateTypeId = '27450541-8e31-4150-9947-dc59f998fc01' - } - # The default is Scrum - Default { - $templateTypeId = '6b724908-ef14-45cf-84f8-768b5384da45' - } + _buildProcessNameDynamicParam -ParameterName 'ProcessTemplate' -Mandatory $false } - if ($TFVC.IsPresent) { - $srcCtrl = "Tfvc" - } + process { + # Bind the parameter to a friendly variable + $ProcessTemplate = $PSBoundParameters["ProcessTemplate"] - $body = '{"name": "' + $ProjectName + '", "description": "' + $Description + '", "capabilities": {"versioncontrol": { "sourceControlType": "' + $srcCtrl + '"}, "processTemplate":{"templateTypeId": "' + $templateTypeId + '"}}}' + $srcCtrl = 'Git' + #Default to Scrum Process Template + $templateTypeId = '6b724908-ef14-45cf-84f8-768b5384da45' - try { - # Call the REST API - $resp = _callAPI -Area 'projects' ` - -Method Post -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Core) + if ($TFVC.IsPresent) { + $srcCtrl = "Tfvc" + } - _trackProjectProgress -resp $resp -title 'Creating team project' -msg "Name: $($ProjectName), Template: $($processTemplate), Src: $($srcCtrl)" + if ($ProcessTemplate) + { + $templateTypeId = (Get-VSTeamProcess -Name $ProcessTemplate).Id + } - # Invalidate any cache of projects. - [VSTeamProjectCache]::timestamp = -1 + $body = '{"name": "' + $ProjectName + '", "description": "' + $Description + '", "capabilities": {"versioncontrol": { "sourceControlType": "' + $srcCtrl + '"}, "processTemplate":{"templateTypeId": "' + $templateTypeId + '"}}}' - return Get-VSTeamProject $ProjectName - } - catch { - _handleException $_ + try { + # Call the REST API + $resp = _callAPI -Area 'projects' ` + -Method Post -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Core) + + _trackProjectProgress -resp $resp -title 'Creating team project' -msg "Name: $($ProjectName), Template: $($processTemplate), Src: $($srcCtrl)" + + # Invalidate any cache of projects. + [VSTeamProjectCache]::timestamp = -1 + + return Get-VSTeamProject $ProjectName + } + catch { + _handleException $_ + } } } diff --git a/src/teamspsdrive.ps1 b/src/teamspsdrive.ps1 index 7b303fba0..6216a48a7 100644 --- a/src/teamspsdrive.ps1 +++ b/src/teamspsdrive.ps1 @@ -90,6 +90,14 @@ class VSTeamProjectCache { static [object] $projects = $null } +# Dynamic parameters get called alot. This can cause +# multiple calls to TFS/VSTS for a single function call +# so I am going to try and cache the values. +class VSTeamProcessCache { + static [int] $timestamp = -1 + static [object] $processes = $null +} + class VSTeamDirectory : SHiPSDirectory { # The object returned from the REST API call [object] hidden $_internalObj = $null @@ -287,6 +295,53 @@ class VSTeamProject : VSTeamDirectory { } } +class VSTeamProcess { + + [string]$ID = $null + [string]$URL = $null + [string]$Description = $null + [string]$Name = $null + [bool]$IsDefault = $false + [string]$Type = $null + + VSTeamProcess ( + [object]$obj + ) { + $this.ID = $obj.id + $this.URL = $obj.url + $this.IsDefault = $obj.isDefault + $this.Name = $obj.name + $this.Type = $obj.type + + # The description is not always returned so protect yourself. + if ($obj.PSObject.Properties.Match('description').count -gt 0) { + $this.Description = $obj.description + } + + $this.AddTypeName('Team.Process') + } + + [void] hidden AddTypeName( + [string] $name + ) { + # The type is used to identify the correct formatter to use. + # The format for when it is returned by the function and + # returned by the provider are different. Adding a type name + # identifies how to format the type. + # When returned by calling the function and not the provider. + # This will be formatted without a mode column. + # When returned by calling the provider. + # This will be formatted with a mode column like a file or + # directory. + $this.PSObject.TypeNames.Insert(0, $name) + } + + [string]ToString() { + return $this.Name + } +} + + [SHiPSProvider(UseCache = $true)] [SHiPSProvider(BuiltinProgress = $false)] class VSTeamExtensions : VSTeamDirectory { diff --git a/unit/test/mocks/mockProcessNameDynamicParam.ps1 b/unit/test/mocks/mockProcessNameDynamicParam.ps1 new file mode 100644 index 000000000..a1f028d34 --- /dev/null +++ b/unit/test/mocks/mockProcessNameDynamicParam.ps1 @@ -0,0 +1,53 @@ +Mock _buildProcessNameDynamicParam { + param( + # Set the dynamic parameters' name + $ParameterName = 'ProcessName', + $ParameterSetName, + $AliasName, + $Mandatory = $true + ) + + # Create the dictionary + $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary + # Create the collection of attributes + $AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute] + # Create and set the parameters' attributes + $ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute + $ParameterAttribute.Mandatory = $Mandatory + $ParameterAttribute.Position = 0 + $ParameterAttribute.ParameterSetName = $ParameterSetName + $ParameterAttribute.ValueFromPipelineByPropertyName = $true + + if ($AliasName) { + $AliasAttribute = New-Object System.Management.Automation.AliasAttribute(@($AliasName)) + $AttributeCollection.Add($AliasAttribute) + } + + # Add the attributes to the attributes collection + $AttributeCollection.Add($ParameterAttribute) + # Create and return the dynamic parameter + $RuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($ParameterName, [string], $AttributeCollection) + $RuntimeParameterDictionary.Add($ParameterName, $RuntimeParameter) + return $RuntimeParameterDictionary +} + +Mock _buildDynamicParam { + param( + # Set the dynamic parameters' name + $ParameterName + ) + + # Create the dictionary + $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary + # Create the collection of attributes + $AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute] + # Create and set the parameters' attributes + $ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute + $ParameterAttribute.Mandatory = $false + $ParameterAttribute.Position = 1 + $ParameterAttribute.ValueFromPipelineByPropertyName = $true + # Add the attributes to the attributes collection + $AttributeCollection.Add($ParameterAttribute) + # Create and return the dynamic parameter + return New-Object System.Management.Automation.RuntimeDefinedParameter($ParameterName, [string], $AttributeCollection) +} \ No newline at end of file diff --git a/unit/test/processes.Tests.ps1 b/unit/test/processes.Tests.ps1 new file mode 100644 index 000000000..73fa46f7e --- /dev/null +++ b/unit/test/processes.Tests.ps1 @@ -0,0 +1,107 @@ +Set-StrictMode -Version Latest + +InModuleScope processes { + [VSTeamVersions]::Account = 'https://dev.azure.com/test' + + Describe 'Process' { + . "$PSScriptRoot\mocks\mockProcessNameDynamicParam.ps1" + + $results = [PSCustomObject]@{ + value = [PSCustomObject]@{ + name = 'Test' + description = '' + url = '' + id = '123-5464-dee43' + isDefault = 'false' + type = 'Agile' + } + } + + $singleResult = [PSCustomObject]@{ + name = 'Test' + description = '' + url = '' + id = '123-5464-dee43' + isDefault = 'false' + type = 'Agile' + } + + Context 'Get-VSTeamProcess with no parameters using BearerToken' { + + Mock Invoke-RestMethod { return $results } + + It 'Should return process' { + Get-VSTeamProcess + + # Make sure it was called with the correct URI + Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter { + $Uri -like "*https://dev.azure.com/test/_apis/process/processes/*" -and + $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and + $Uri -like "*`$top=100*" + } + } + } + + Context 'Get-VSTeamProcess with top 10' { + + Mock Invoke-RestMethod { return $results } + + It 'Should return top 10 process' { + Get-VSTeamProcess -top 10 + + # Make sure it was called with the correct URI + Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter { + $Uri -like "*https://dev.azure.com/test/_apis/process/processes/*" -and + $Uri -like "*`$top=10*" + } + } + } + + Context 'Get-VSTeamProcess with skip 1' { + + Mock Invoke-RestMethod { return $results } + + It 'Should skip first process' { + Get-VSTeamProcess -skip 1 + + # Make sure it was called with the correct URI + Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter { + $Uri -like "*https://dev.azure.com/test/_apis/process/processes/*" -and + $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and + $Uri -like "*`$skip=1*" -and + $Uri -like "*`$top=100*" + } + } + } + + Context 'Get-VSTeamProcess by Name' { + #Although this returns a single VSTeamProcess instance, the REST call returns multiple results + Mock Invoke-RestMethod { return $results } + + It 'Should return Process by Name' { + Get-VSTeamProcess -Name Agile + + # Make sure it was called with the correct URI + Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter { + $Uri -like "*https://dev.azure.com/test/_apis/process/processes/*" -and + $Uri -like "*api-version=$([VSTeamVersions]::Core)*" + } + } + } + + Context 'Get-VSTeamProcess by Id' { + + Mock Invoke-RestMethod { return $singleResult } + + It 'Should return Process by Id' { + Get-VSTeamProcess -Id '123-5464-dee43' + + # Make sure it was called with the correct URI + Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter { + $Uri -like "*https://dev.azure.com/test/_apis/process/processes/*" -and + $Uri -like "*api-version=$([VSTeamVersions]::Core)*" + } + } + } + } +} \ No newline at end of file From 70757d05dfde6ec3c7feead54ffdae50fba48ed3 Mon Sep 17 00:00:00 2001 From: Paul Ballard Date: Wed, 16 Jan 2019 23:08:12 -0600 Subject: [PATCH 2/6] Touching up Help --- .docs/Add-VSTeamProject.md | 4 +--- en-US/about_vsteam.help.txt | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.docs/Add-VSTeamProject.md b/.docs/Add-VSTeamProject.md index 19f615bd1..34889b79f 100644 --- a/.docs/Add-VSTeamProject.md +++ b/.docs/Add-VSTeamProject.md @@ -51,11 +51,9 @@ The name of the process template to use for the project. You can tab complete from a list of available projects. -Will use the default process template if one is not provided - ```yaml Type: String -Default value: [Determined by Default Process Template definition] +Default value: Scrum ``` ### -Description diff --git a/en-US/about_vsteam.help.txt b/en-US/about_vsteam.help.txt index ace3fdb24..ba900f32f 100644 --- a/en-US/about_vsteam.help.txt +++ b/en-US/about_vsteam.help.txt @@ -36,6 +36,7 @@ LONG DESCRIPTION · Build · Build Definitions · Core + · Processes · Projects · Team Members · Teams From 74473bd8b4499a79f1f7f393e23bc2317616e0c9 Mon Sep 17 00:00:00 2001 From: Paul Ballard Date: Wed, 16 Jan 2019 23:10:36 -0600 Subject: [PATCH 3/6] Touching up Changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82f52f300..517078433 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 5.0.1 +Added Get-VSTeamProcess +Modified Add-VSTeamProcess to allow for any Process Template to be used + ## 5.0.0 **Breaking changes**: From aa3efd75c134cdf8b3b4efc33e629cb99b6b6839 Mon Sep 17 00:00:00 2001 From: Paul Ballard Date: Fri, 18 Jan 2019 10:48:08 -0600 Subject: [PATCH 4/6] Adding formatted views --- VSTeam.psd1 | 1 - formats/vsteamPSDrive.format.ps1xml | 59 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/VSTeam.psd1 b/VSTeam.psd1 index 39c548fa9..43b4f7d2b 100644 --- a/VSTeam.psd1 +++ b/VSTeam.psd1 @@ -268,7 +268,6 @@ 'Add-GitRepository', 'Remove-GitRepository', 'Get-Pool', - 'Get-Process', 'Get-Project', 'Show-Project', 'Update-Project', diff --git a/formats/vsteamPSDrive.format.ps1xml b/formats/vsteamPSDrive.format.ps1xml index 943b105a7..445869dee 100644 --- a/formats/vsteamPSDrive.format.ps1xml +++ b/formats/vsteamPSDrive.format.ps1xml @@ -1180,6 +1180,65 @@ + + + Team.ProcessTable + + Team.Process + + + + + + + + + + + + + + + + + Name + + + Description + + + + + + + + + + ProessListView + + Team.Process + Team.Provider.Process + VSTeamProcess + + + + + + + Name + + + ID + + + Description + + + + + + + From e6286eff0ffeb63cc7cf54581b7a8283a7715d86 Mon Sep 17 00:00:00 2001 From: Donovan Brown Date: Sun, 20 Jan 2019 01:11:11 -0600 Subject: [PATCH 5/6] Fixed two failing tests. --- src/processes.psm1 | 8 ++++---- src/projects.psm1 | 5 ++--- unit/test/projects.Tests.ps1 | 3 +++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/processes.psm1 b/src/processes.psm1 index f77a9ffbb..ac2bd9151 100644 --- a/src/processes.psm1 +++ b/src/processes.psm1 @@ -41,19 +41,19 @@ function Get-VSTeamProcess { Write-Output $project } elseif ($ProcessName) { - #Lookup Process ID by Name + # Lookup Process ID by Name Get-VSTeamProcess | where-object {$_.name -eq $ProcessName} } else { - #return list of processes + # Return list of processes try { # Call the REST API $resp = _callAPI -Area 'process/processes' ` -Version $([VSTeamVersions]::Core) ` -QueryString @{ - '$top' = $top - '$skip' = $skip + '$top' = $top + '$skip' = $skip } $objs = @() diff --git a/src/projects.psm1 b/src/projects.psm1 index 662629140..091e51f8d 100644 --- a/src/projects.psm1 +++ b/src/projects.psm1 @@ -234,9 +234,8 @@ function Add-VSTeamProject { $srcCtrl = "Tfvc" } - if ($ProcessTemplate) - { - $templateTypeId = (Get-VSTeamProcess -Name $ProcessTemplate).Id + if ($ProcessTemplate) { + $templateTypeId = (Get-VSTeamProcess -Name $ProcessTemplate).Id } $body = '{"name": "' + $ProjectName + '", "description": "' + $Description + '", "capabilities": {"versioncontrol": { "sourceControlType": "' + $srcCtrl + '"}, "processTemplate":{"templateTypeId": "' + $templateTypeId + '"}}}' diff --git a/unit/test/projects.Tests.ps1 b/unit/test/projects.Tests.ps1 index 553b475b2..91cf0bd92 100644 --- a/unit/test/projects.Tests.ps1 +++ b/unit/test/projects.Tests.ps1 @@ -5,6 +5,7 @@ InModuleScope projects { Describe 'Project' { . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1" + . "$PSScriptRoot\mocks\mockProcessNameDynamicParam.ps1" Context 'Show-VSTeamProject by ID' { Mock Show-Browser @@ -292,6 +293,7 @@ InModuleScope projects { Mock Invoke-RestMethod { return @{status = 'inProgress'; id = 1; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://dev.azure.com/test/_apis/projects/?api-version=$([VSTeamVersions]::Core)"} Mock _trackProjectProgress Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://dev.azure.com/test/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" } + Mock Get-VSTeamProcess { return @{name = 'Agile'; id = 1}} It 'Should create project with Agile' { Add-VSTeamProject -ProjectName Test -processTemplate Agile @@ -306,6 +308,7 @@ InModuleScope projects { Mock Invoke-RestMethod { return @{status = 'inProgress'; id = 1; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://dev.azure.com/test/_apis/projects/?api-version=$([VSTeamVersions]::Core)"} Mock _trackProjectProgress Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://dev.azure.com/test/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" } + Mock Get-VSTeamProcess { return @{name = 'CMMI'; id = 1}} It 'Should create project with CMMI' { Add-VSTeamProject -ProjectName Test -processTemplate CMMI From 24341a67dbcdaa80bbbe55b2b387a4d81e72c918 Mon Sep 17 00:00:00 2001 From: Donovan Brown Date: Sun, 20 Jan 2019 01:16:47 -0600 Subject: [PATCH 6/6] Update version to 5.0.1 --- CHANGELOG.md | 7 +++++-- VSTeam.psd1 | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 517078433..a97dd6231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Changelog ## 5.0.1 -Added Get-VSTeamProcess -Modified Add-VSTeamProcess to allow for any Process Template to be used + +Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/128) from [Fifth Street Partners](https://github.com/fifthstreetpartners) which included the following: + +- Added Get-VSTeamProcess +- Modified Add-VSTeamProcess to allow for any Process Template to be used ## 5.0.0 diff --git a/VSTeam.psd1 b/VSTeam.psd1 index 43b4f7d2b..a2c5407be 100644 --- a/VSTeam.psd1 +++ b/VSTeam.psd1 @@ -13,7 +13,7 @@ RootModule = '' # Version number of this module. - ModuleVersion = '5.0.0' + ModuleVersion = '5.0.1' # Supported PSEditions # CompatiblePSEditions = @()