Skip to content

Commit e0550ff

Browse files
Merge pull request #126 from StartAutomating/Convert-BuildStep-Improvements
Convert-BuildStep Improvements:
2 parents 6390480 + ff3afc5 commit e0550ff

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

Convert-BuildStep.ps1

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@
385385
if ([switch], [bool] -contains $paramType) {
386386
"`$Parameters.$ParameterName = `$parameters.$ParameterName -match 'true';"
387387
}
388+
if ([psobject], [object],[PSObject[]] -contains $paramType) {
389+
"`$Parameters.$ParameterName = ConvertFrom-JSON @'" +
390+
[Environment]::NewLine +
391+
'${{parameters.$ParameterName}}' + [Environment]::NewLine + "'@"
392+
}
388393
# If the parameter type was a scriptblock
389394
if ([ScriptBlock], [ScriptBlock[]] -contains $paramType) {
390395
"`$Parameters.$ParameterName = foreach (`$p in `$parameters.$ParameterName){ [ScriptBlock]::Create(`$p) }"
@@ -470,8 +475,13 @@ try {
470475
} else {
471476
$out.powershell = "$innerScript" -replace '`\$\{','${'
472477
}
478+
if ($ScriptBlock -and $ScriptBlock.Attributes) {
479+
if ("$($ScriptBlock.Attributes.ConditionString)") {
480+
$out.condition = "$($ScriptBlock.Attributes.ConditionString)"
481+
}
482+
}
473483
$out.name = $Name
474-
$out.displayName = $Name
484+
$out.displayName = $Name
475485
if ($definedParameters) {
476486
$out.parameters = $definedParameters
477487
}
@@ -505,6 +515,23 @@ try {
505515
}
506516
$out.run = "$innerScript" -replace '`\$\{','${'
507517
}
518+
if ($ScriptBlock -and $ScriptBlock.Attributes.Key -ne '') { # If the scriptblock has .Attributes with .Key properties
519+
foreach ($attr in $ScriptBlock.Attributes) { # each of those attributes
520+
if ($attr -isnot [Reflection.AssemblyMetadataAttribute]) { continue }
521+
if ($out.($attr.Key)) { # If it already had the key, use the original case.
522+
$originalNameCase =
523+
foreach ($prop in $out.psobject.properties) {
524+
if ($prop.Name -eq $attr.Key) {
525+
$prop.Name
526+
break
527+
}
528+
}
529+
$out.$originalNameCase = $attr.Value
530+
} else {
531+
$out.($attr.Key) = $attr.value
532+
}
533+
}
534+
}
508535
$out
509536
}
510537
}

PSDevOps.psd1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.5.5'
2+
ModuleVersion = '0.5.5.1'
33
RootModule = 'PSDevOps.psm1'
44
Description = 'PowerShell Tools for DevOps'
55
Guid = 'e6b56c5f-41ac-4ba4-8b88-2c063f683176'
@@ -9,6 +9,11 @@
99
ProjectURI = 'https://github.com/StartAutomating/PSDevOps'
1010
LicenseURI = 'https://github.com/StartAutomating/PSDevOps/blob/master/LICENSE'
1111
ReleaseNotes = @'
12+
0.5.5.1:
13+
---
14+
* Allowing for [Reflection.AssemblyMetaData] attributes on step .ps1 files (to customize YAML). Issue #123
15+
* Better support for Object and array parameters in Azure DevOps. Issue #125.
16+
1217
0.5.5:
1318
---
1419
* Azure DevOps: Adding support for Shared Queries (Fixes #117)

PSDevOps.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ describe 'Calling REST APIs' {
340340
}
341341
it 'Can get build definitions' {
342342
$buildDefinitions = @(Get-ADOBuild -Organization StartAutomating -Project PSDevOps -Definition)
343-
$buildDefinitions.Count | should -BeGreaterThan 1
343+
$buildDefinitions.Count | should -BeGreaterThan 0
344344
$buildDefinitions[0].Name |should -beLike *PSDevOps*
345345
}
346346
it 'Can get build -DefinitionYAML, given a build definition' -Skip:$IsFork {

0 commit comments

Comments
 (0)