Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Process Template Support #128

Merged
merged 9 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .docs/Add-VSTeamProject.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ 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.

```yaml
Type: String
Expand Down Expand Up @@ -84,4 +82,6 @@ Type: SwitchParameter

[Add-VSTeamAccount](Add-VSTeamAccount.md)

[Remove-VSTeamProject](Remove-VSTeamProject.md)
[Remove-VSTeamProject](Remove-VSTeamProject.md)

[Get-VSTeamProcess](Get-VSTeamProcess.md)
81 changes: 81 additions & 0 deletions .docs/Get-VSTeamProcess.md
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)
12 changes: 12 additions & 0 deletions .docs/params/processName.md
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)
```
1 change: 1 addition & 0 deletions .docs/synopsis/Get-VSTeamProcess.md
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.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 5.0.1

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

**Breaking changes**:
Expand Down
4 changes: 3 additions & 1 deletion VSTeam.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
RootModule = ''

# Version number of this module.
ModuleVersion = '5.0.0'
ModuleVersion = '5.0.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -142,6 +143,7 @@
'Get-VSTeamPolicy',
'Get-VSTeamPolicyType',
'Get-VSTeamPool',
'Get-VSTeamProcess',
'Get-VSTeamProject',
'Get-VSTeamQueue',
'Get-VSTeamRelease',
Expand Down
1 change: 1 addition & 0 deletions en-US/about_vsteam.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ LONG DESCRIPTION
· Build
· Build Definitions
· Core
· Processes
· Projects
· Team Members
· Teams
Expand Down
59 changes: 59 additions & 0 deletions formats/vsteamPSDrive.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,65 @@
</ListControl>
</View>

<!--Team.ProcessTable-->
<View>
<Name>Team.ProcessTable</Name>
<ViewSelectedBy>
<TypeName>Team.Process</TypeName>
</ViewSelectedBy>
<TableControl>
<AutoSize/>
<TableHeaders>
<TableColumnHeader>
<Label>Name</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Description</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<Wrap/>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Description</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>

<!--ProcessListView-->
<View>
<Name>ProessListView</Name>
<ViewSelectedBy>
<TypeName>Team.Process</TypeName>
<TypeName>Team.Provider.Process</TypeName>
<TypeName>VSTeamProcess</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>Name</PropertyName>
</ListItem>
<ListItem>
<PropertyName>ID</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Description</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>

<!-- Put the defaults last because the first matching format is used. -->

<!--Team.Pool.Table-->
Expand Down
108 changes: 108 additions & 0 deletions src/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading