From 8df6c4ae06fc7059a2e0fe58ebe62f1497c26c4b Mon Sep 17 00:00:00 2001 From: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com> Date: Mon, 27 Nov 2023 08:27:52 +0100 Subject: [PATCH] Consider CICD workflow run with no build jobs unsuccessful (#835) _Issue_: A CICD workflow run with no build jobs is considered _successful_. _Solution_: Check if the CICD has at least one build job. --- Actions/Github-Helper.psm1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Actions/Github-Helper.psm1 b/Actions/Github-Helper.psm1 index 20d567bfc..b3d564ac2 100644 --- a/Actions/Github-Helper.psm1 +++ b/Actions/Github-Helper.psm1 @@ -728,6 +728,7 @@ function CheckBuildJobsInWorkflowRun { $page = 1 $allSuccessful = $true + $anySuccessful = $false while($true) { $jobsURI = "$api_url/repos/$repository/actions/runs/$WorkflowRunId/jobs?per_page=$per_page&page=$page" @@ -738,22 +739,23 @@ function CheckBuildJobsInWorkflowRun { # No more jobs, breaking out of the loop break } + $buildJobs = @($workflowJobs.jobs | Where-Object { $_.name.StartsWith('Build ') }) + if($buildJobs.conclusion -eq 'success') { + $anySuccessful = $true + } + if($buildJobs.conclusion -ne 'success') { # If there is a build job that is not successful, there is not need to check further $allSuccessful = $false - } - - if(-not $allSuccessful) { - # there is a non-successful build job, no need to check further break } $page += 1 } - return $allSuccessful + return ($allSuccessful -and $anySuccessful) } <#