Path: blob/main/build/azure-pipelines/common/waitForArtifacts.js
3520 views
"use strict";1Object.defineProperty(exports, "__esModule", { value: true });2/*---------------------------------------------------------------------------------------------3* Copyright (c) Microsoft Corporation. All rights reserved.4* Licensed under the MIT License. See License.txt in the project root for license information.5*--------------------------------------------------------------------------------------------*/6const publish_1 = require("../common/publish");7const retry_1 = require("../common/retry");8async function getPipelineArtifacts() {9const result = await (0, publish_1.requestAZDOAPI)('artifacts');10return result.value.filter(a => !/sbom$/.test(a.name));11}12async function main(artifacts) {13if (artifacts.length === 0) {14throw new Error(`Usage: node waitForArtifacts.js <artifactName1> <artifactName2> ...`);15}16// This loop will run for 30 minutes and waits to the x64 and arm64 artifacts17// to be uploaded to the pipeline by the `macOS` and `macOSARM64` jobs. As soon18// as these artifacts are found, the loop completes and the `macOSUnivesrsal`19// job resumes.20for (let index = 0; index < 60; index++) {21try {22console.log(`Waiting for artifacts (${artifacts.join(', ')}) to be uploaded (${index + 1}/60)...`);23const allArtifacts = await (0, retry_1.retry)(() => getPipelineArtifacts());24console.log(` * Artifacts attached to the pipelines: ${allArtifacts.length > 0 ? allArtifacts.map(a => a.name).join(', ') : 'none'}`);25const foundArtifacts = allArtifacts.filter(a => artifacts.includes(a.name));26console.log(` * Found artifacts: ${foundArtifacts.length > 0 ? foundArtifacts.map(a => a.name).join(', ') : 'none'}`);27if (foundArtifacts.length === artifacts.length) {28console.log(` * All artifacts were found`);29return;30}31}32catch (err) {33console.error(`ERROR: Failed to get pipeline artifacts: ${err}`);34}35await new Promise(c => setTimeout(c, 30_000));36}37throw new Error(`ERROR: Artifacts (${artifacts.join(', ')}) were not uploaded within 30 minutes.`);38}39main(process.argv.splice(2)).then(() => {40process.exit(0);41}, err => {42console.error(err);43process.exit(1);44});45//# sourceMappingURL=waitForArtifacts.js.map4647