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

Update Add-VSTeamBuild to support template parameters #468

Merged
merged 5 commits into from
Sep 3, 2022
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## 7.9.0
Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/468) from [Michael19842](https://github.com/Michael19842) the following:
- Added parameter `Templateparameter` for queue new build with custom template parameters

## 7.8.0
Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/475) from [rbleattler](https://github.com/rbleattler) the following:
- Added Update-VSTeamGitRepositoryDefaultBranch to allow for changing the default branch of a repository

## 7.7.0
Expand Down
7 changes: 7 additions & 0 deletions Source/Public/Add-VSTeamBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function Add-VSTeamBuild {
[Parameter(Mandatory = $false)]
[hashtable] $BuildParameters,

[Parameter(Mandatory = $false)]
[hashtable] $TemplateParameters,

[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[vsteam_lib.ProjectValidateAttribute($false)]
[ArgumentCompleter([vsteam_lib.ProjectCompleter])]
Expand Down Expand Up @@ -77,6 +80,10 @@ function Add-VSTeamBuild {
$body.Add('parameters', ($BuildParameters | ConvertTo-Json -Depth 100 -Compress))
}

if ($TemplateParameters) {
$body.Add('templateParameters', $TemplateParameters)
}

$resp = _callAPI -Method POST -ProjectName $ProjectName `
-Area "build" `
-Resource "builds" `
Expand Down
2 changes: 1 addition & 1 deletion Source/VSTeam.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'VSTeam.psm1'

# Version number of this module.
ModuleVersion = '7.8.0'
ModuleVersion = '7.9.0'

# Supported PSEditions
CompatiblePSEditions = @('Core', 'Desktop')
Expand Down
21 changes: 21 additions & 0 deletions Tests/function/tests/Add-VSTeamBuild.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ Describe 'VSTeamBuild' {
$Uri -eq "https://dev.azure.com/test/project/_apis/build/builds?api-version=$(_getApiVersion Build)"
}
}

It 'should add build with templateParameters' {
## Act
Add-VSTeamBuild -ProjectName project `
-BuildDefinitionId 2 `
-TemplateParameters @{
'Param1' = 'Val1'
'Param2' = 'Val2'
}

## Assert
# Call to queue build.
Should -Invoke Invoke-RestMethod -Exactly -Times 1 -Scope It -ParameterFilter {
$Body -like "*2*" -and
$Body -like "*Param1*" -and
$Body -like "*Param2*" -and
$Body -like "*Val2*" -and
$Body -like "*Val1*" -and
$Uri -eq "https://dev.azure.com/test/project/_apis/build/builds?api-version=$(_getApiVersion Build)"
}
}
}

Context 'Server' -Tag "Server" {
Expand Down