Skip to content

Commit 0c60517

Browse files
committed
Support parameterization of arrays in CICD script
1 parent d5d9902 commit 0c60517

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function Compare-TriggerPayload {
228228
return $True
229229
}
230230
catch {
231-
Write-Host "##[warning] Unable to compare payload for '$($triggerDeployed.Name)' trigger, this is not a failure. You can post the issue to https://github.com/Azure/Azure-DataFactory/issues to check if this can be addressed."
231+
Write-Host "##[warning] Unable to compare payload for '$($triggerDeployed.Name)' trigger, this is not a failure. You can post the issue to https://github.com/Azure/Azure-DataFactory/issues to check if this is user error or limitation."
232232
Write-Host "##[warning] $_ from Line: $($_.InvocationInfo.ScriptLineNumber)"
233233
return $True;
234234
}
@@ -467,7 +467,15 @@ function Update-TriggerTemplate {
467467
foreach ($parameterMatch in $parameterMatches) {
468468
$parameterName = $parameterMatch.Value.Substring(13, $parameterMatch.Value.Length - 16)
469469
if ($null -ne $templateParameters.$($parameterName)) {
470-
$templateJson = $templateJson -replace [System.Text.RegularExpressions.Regex]::Escape($parameterMatch.Value), $templateParameters.$($parameterName).value
470+
$parameterType = $templateParameters.$($parameterName).value ? $templateParameters.$($parameterName).value.GetType().Name : $null
471+
if ($parameterType -eq 'Object[]') {
472+
$parameterValue = ConvertTo-Json $templateParameters.$($parameterName).value
473+
$templateJson = $templateJson -replace [System.Text.RegularExpressions.Regex]::Escape("`"$($parameterMatch.Value)`""), $parameterValue
474+
} elseif ($parameterType -eq 'Boolean' -or $parameterType -eq 'Int64') {
475+
$templateJson = $templateJson -replace [System.Text.RegularExpressions.Regex]::Escape("`"$($parameterMatch.Value)`""), $templateParameters.$($parameterName).value
476+
} else {
477+
$templateJson = $templateJson -replace [System.Text.RegularExpressions.Regex]::Escape($parameterMatch.Value), $templateParameters.$($parameterName).value
478+
}
471479
}
472480
}
473481

0 commit comments

Comments
 (0)