Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/common/checkForArtifact.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Artifact, requestAZDOAPI } from './publish';
7
import { retry } from './retry';
8
9
async function getPipelineArtifacts(): Promise<Artifact[]> {
10
const result = await requestAZDOAPI<{ readonly value: Artifact[] }>('artifacts');
11
return result.value.filter(a => !/sbom$/.test(a.name));
12
}
13
14
async function main([variableName, artifactName]: string[]): Promise<void> {
15
if (!variableName || !artifactName) {
16
throw new Error(`Usage: node checkForArtifact.js <variableName> <artifactName>`);
17
}
18
19
try {
20
const artifacts = await retry(() => getPipelineArtifacts());
21
const artifact = artifacts.find(a => a.name === artifactName);
22
console.log(`##vso[task.setvariable variable=${variableName}]${artifact ? 'true' : 'false'}`);
23
} catch (err) {
24
console.error(`ERROR: Failed to get pipeline artifacts: ${err}`);
25
console.log(`##vso[task.setvariable variable=${variableName}]false`);
26
}
27
}
28
29
main(process.argv.slice(2))
30
.then(() => {
31
process.exit(0);
32
}, err => {
33
console.error(err);
34
process.exit(1);
35
});
36
37