Path: blob/main/build/azure-pipelines/common/checkForArtifact.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("./publish");7const retry_1 = require("./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([variableName, artifactName]) {13if (!variableName || !artifactName) {14throw new Error(`Usage: node checkForArtifact.js <variableName> <artifactName>`);15}16try {17const artifacts = await (0, retry_1.retry)(() => getPipelineArtifacts());18const artifact = artifacts.find(a => a.name === artifactName);19console.log(`##vso[task.setvariable variable=${variableName}]${artifact ? 'true' : 'false'}`);20}21catch (err) {22console.error(`ERROR: Failed to get pipeline artifacts: ${err}`);23console.log(`##vso[task.setvariable variable=${variableName}]false`);24}25}26main(process.argv.slice(2))27.then(() => {28process.exit(0);29}, err => {30console.error(err);31process.exit(1);32});33//# sourceMappingURL=checkForArtifact.js.map3435