forked from MethodsAndPractices/vsteam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from fifthstreetpartners/feature/add-process-su…
…pport Adding Process Template Support
- Loading branch information
Showing
11 changed files
with
535 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!-- #include "./common/header.md" --> | ||
|
||
# Get-VSTeamProcess | ||
|
||
## SYNOPSIS | ||
|
||
<!-- #include "./synopsis/Get-VSTeamProcess.md" --> | ||
|
||
## 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 | ||
|
||
<!-- #include "./params/ProcessName.md" --> | ||
|
||
### -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Returns a list of process templates in the Team Services or Team Foundation Server account. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 $_ | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.