Skip to content

Commit

Permalink
Merge pull request #126 from StartAutomating/Convert-BuildStep-Improv…
Browse files Browse the repository at this point in the history
…ements

Convert-BuildStep Improvements:
  • Loading branch information
StartAutomating authored Oct 13, 2021
2 parents 6390480 + ff3afc5 commit e0550ff
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
29 changes: 28 additions & 1 deletion Convert-BuildStep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@
if ([switch], [bool] -contains $paramType) {
"`$Parameters.$ParameterName = `$parameters.$ParameterName -match 'true';"
}
if ([psobject], [object],[PSObject[]] -contains $paramType) {
"`$Parameters.$ParameterName = ConvertFrom-JSON @'" +
[Environment]::NewLine +
'${{parameters.$ParameterName}}' + [Environment]::NewLine + "'@"
}
# If the parameter type was a scriptblock
if ([ScriptBlock], [ScriptBlock[]] -contains $paramType) {
"`$Parameters.$ParameterName = foreach (`$p in `$parameters.$ParameterName){ [ScriptBlock]::Create(`$p) }"
Expand Down Expand Up @@ -470,8 +475,13 @@ try {
} else {
$out.powershell = "$innerScript" -replace '`\$\{','${'
}
if ($ScriptBlock -and $ScriptBlock.Attributes) {
if ("$($ScriptBlock.Attributes.ConditionString)") {
$out.condition = "$($ScriptBlock.Attributes.ConditionString)"
}
}
$out.name = $Name
$out.displayName = $Name
$out.displayName = $Name
if ($definedParameters) {
$out.parameters = $definedParameters
}
Expand Down Expand Up @@ -505,6 +515,23 @@ try {
}
$out.run = "$innerScript" -replace '`\$\{','${'
}
if ($ScriptBlock -and $ScriptBlock.Attributes.Key -ne '') { # If the scriptblock has .Attributes with .Key properties
foreach ($attr in $ScriptBlock.Attributes) { # each of those attributes
if ($attr -isnot [Reflection.AssemblyMetadataAttribute]) { continue }
if ($out.($attr.Key)) { # If it already had the key, use the original case.
$originalNameCase =
foreach ($prop in $out.psobject.properties) {
if ($prop.Name -eq $attr.Key) {
$prop.Name
break
}
}
$out.$originalNameCase = $attr.Value
} else {
$out.($attr.Key) = $attr.value
}
}
}
$out
}
}
7 changes: 6 additions & 1 deletion PSDevOps.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.5.5'
ModuleVersion = '0.5.5.1'
RootModule = 'PSDevOps.psm1'
Description = 'PowerShell Tools for DevOps'
Guid = 'e6b56c5f-41ac-4ba4-8b88-2c063f683176'
Expand All @@ -9,6 +9,11 @@
ProjectURI = 'https://github.com/StartAutomating/PSDevOps'
LicenseURI = 'https://github.com/StartAutomating/PSDevOps/blob/master/LICENSE'
ReleaseNotes = @'
0.5.5.1:
---
* Allowing for [Reflection.AssemblyMetaData] attributes on step .ps1 files (to customize YAML). Issue #123
* Better support for Object and array parameters in Azure DevOps. Issue #125.
0.5.5:
---
* Azure DevOps: Adding support for Shared Queries (Fixes #117)
Expand Down
2 changes: 1 addition & 1 deletion PSDevOps.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe 'Calling REST APIs' {
}
it 'Can get build definitions' {
$buildDefinitions = @(Get-ADOBuild -Organization StartAutomating -Project PSDevOps -Definition)
$buildDefinitions.Count | should -BeGreaterThan 1
$buildDefinitions.Count | should -BeGreaterThan 0
$buildDefinitions[0].Name |should -beLike *PSDevOps*
}
it 'Can get build -DefinitionYAML, given a build definition' -Skip:$IsFork {
Expand Down

0 comments on commit e0550ff

Please sign in to comment.