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