From 6d5eaeacf0abdc1483821dbaab192b4f0c54fd32 Mon Sep 17 00:00:00 2001 From: adjurdjevic <57809871+adjurdjevic@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:38:32 +0200 Subject: [PATCH] add guard clause to skip artifact with missing build associated (#1967) Co-authored-by: Aleksandar Djurdjevic --- .../src/ReleaseNotesFunctions.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Extensions/XplatGenerateReleaseNotes/XplatGenerateReleaseNotesTask/src/ReleaseNotesFunctions.ts b/Extensions/XplatGenerateReleaseNotes/XplatGenerateReleaseNotesTask/src/ReleaseNotesFunctions.ts index 942d7a318..e1d1f36c6 100644 --- a/Extensions/XplatGenerateReleaseNotes/XplatGenerateReleaseNotesTask/src/ReleaseNotesFunctions.ts +++ b/Extensions/XplatGenerateReleaseNotes/XplatGenerateReleaseNotesTask/src/ReleaseNotesFunctions.ts @@ -210,8 +210,11 @@ export async function restoreAzurePipelineArtifactsBuildInfo(artifactsInRelease: const [packageId, packageVersion] = [artifactInRelease.buildDefinitionId, artifactInRelease.buildNumber]; const artifactPackageInfo = await packagingApi.getPackage(projectId, feedId, packageId, true); const packageVersionId = (artifactPackageInfo.versions.find((version) => version.normalizedVersion === packageVersion) || {id: ""}).id; - const artifactBuildInfo = (await packagingApi.getPackageVersionProvenance(projectId, feedId, packageId, packageVersionId)); - + const artifactBuildInfo = await packagingApi.getPackageVersionProvenance(projectId, feedId, packageId, packageVersionId); + if (!artifactBuildInfo.provenance.data["Build.BuildId"]) { + agentApi.logInfo(`No build ID found for Azure Artifact [${artifactInRelease.artifactAlias}]. Skipping this artifact.`); + continue; // Guard clause for missing build ID + } Object.assign(artifactInRelease, { artifactType: "Build", buildId: artifactBuildInfo.provenance.data["Build.BuildId"],