From caa2884e5b0037dd99d6b6a6efba6745d1cf1e5a Mon Sep 17 00:00:00 2001 From: Luiza Oancea Date: Wed, 31 Jul 2024 13:41:10 +0200 Subject: [PATCH] Refactor the `Push-PipelinesToList` function in `PrePostDeploymentScript.Ver2.ps1` to improve pipeline dependency handling. If a dependency is null, display a warning message. Otherwise, recursively call `Push-PipelinesToList` with the dependent pipeline. --- .../PrePostDeploymentScript.Ver2.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 b/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 index 0227a49f..5525fd02 100644 --- a/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 +++ b/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1 @@ -79,8 +79,15 @@ function Push-PipelinesToList { return; } $visited[$pipeline.Name] = $true; - $pipeline.Activities | ForEach-Object { Get-PipelineDependency -activity $_ -pipelineNameResourceDict $pipelineNameResourceDict } | ForEach-Object { - Push-PipelinesToList -pipeline $pipelineNameResourceDict[$_] -pipelineNameResourceDict $pipelineNameResourceDict -visited $visited -sortedList $sortedList + foreach ($activity in $pipeline.Activities) { + $activityName = $activity.Name + Get-PipelineDependency -activity $activity -pipelineNameResourceDict $pipelineNameResourceDict + } foreach ($dependency in $dependecies) { + if ($null -eq $dependency) { + Write-Warning "Warning: Pipeline dependency is null for pipeline $($pipeline.Name) and activity $activityName. The activity $activityName is missing an invoked pipeline reference." + } else { + Push-PipelinesToList -pipeline $pipelineNameResourceDict[$dependency] -pipelineNameResourceDict $pipelineNameResourceDict -visited $visited -sortedList $sortedList + } } $sortedList.Push($pipeline) }