From 39c0737d5223a1aba11d2a65189ad7458691952d Mon Sep 17 00:00:00 2001 From: Aurel Schwitter Date: Thu, 23 Feb 2023 13:56:52 +0100 Subject: [PATCH 1/2] Skip comparing parameter values that are both null (#540) --- .../PrePostDeploymentScript.Ver2.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 b/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 index fef3e700..ab8cc879 100644 --- a/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 +++ b/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 @@ -425,7 +425,12 @@ function Compare-TriggerPipelineReference { Write-Host "##[warning] SecureString parameter is always treated as a change" break } else { - $paramValueChanges = Compare-Object -ReferenceObject ($deployedValue.ToString() | ConvertFrom-Json) -DifferenceObject ($payloadValue.ToString() | ConvertFrom-Json) + $deployedValueObj = ConvertFrom-Json $deployedValue.ToString() + $payloadValueObj = ConvertFrom-Json $payloadValue.ToString() + # when both are null, do not compare them + if ($null -ne $deployedValueObj -and $null -ne $payloadValueObj) { + $paramValueChanges = Compare-Object -ReferenceObject $deployedValueObj -DifferenceObject $payloadValueObj + } } } elseif ($deployedValue.GetType().Name -eq "Boolean") { $paramValueChanges = Compare-Object -ReferenceObject ($deployedValue.ToString().ToLower() | ConvertFrom-Json) -DifferenceObject ($payloadValue.ToString().ToLower() | ConvertFrom-Json) From cd9d4c9972369ad31eeed1a24467398c93de8464 Mon Sep 17 00:00:00 2001 From: Aurel Schwitter Date: Thu, 23 Feb 2023 17:03:40 +0100 Subject: [PATCH 2/2] Fix wrong or logic in statement --- .../PrePostDeploymentScript.Ver2.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 b/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 index ab8cc879..7d12c8ba 100644 --- a/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 +++ b/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 @@ -427,8 +427,9 @@ function Compare-TriggerPipelineReference { } else { $deployedValueObj = ConvertFrom-Json $deployedValue.ToString() $payloadValueObj = ConvertFrom-Json $payloadValue.ToString() - # when both are null, do not compare them - if ($null -ne $deployedValueObj -and $null -ne $payloadValueObj) { + # only compare the objects when one of them is non-null + if ($null -ne $deployedValueObj -or $null -ne $payloadValueObj) { + { $paramValueChanges = Compare-Object -ReferenceObject $deployedValueObj -DifferenceObject $payloadValueObj } }