Path: blob/main/build/azure-pipelines/common/createBuild.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 identity_1 = require("@azure/identity");7const cosmos_1 = require("@azure/cosmos");8const retry_1 = require("./retry");9if (process.argv.length !== 3) {10console.error('Usage: node createBuild.js VERSION');11process.exit(-1);12}13function getEnv(name) {14const result = process.env[name];15if (typeof result === 'undefined') {16throw new Error('Missing env: ' + name);17}18return result;19}20async function main() {21const [, , _version] = process.argv;22const quality = getEnv('VSCODE_QUALITY');23const commit = getEnv('BUILD_SOURCEVERSION');24const queuedBy = getEnv('BUILD_QUEUEDBY');25const sourceBranch = getEnv('BUILD_SOURCEBRANCH');26const version = _version + (quality === 'stable' ? '' : `-${quality}`);27console.log('Creating build...');28console.log('Quality:', quality);29console.log('Version:', version);30console.log('Commit:', commit);31const build = {32id: commit,33timestamp: (new Date()).getTime(),34version,35isReleased: false,36private: process.env['VSCODE_PRIVATE_BUILD']?.toLowerCase() === 'true',37sourceBranch,38queuedBy,39assets: [],40updates: {}41};42const aadCredentials = new identity_1.ClientAssertionCredential(process.env['AZURE_TENANT_ID'], process.env['AZURE_CLIENT_ID'], () => Promise.resolve(process.env['AZURE_ID_TOKEN']));43const client = new cosmos_1.CosmosClient({ endpoint: process.env['AZURE_DOCUMENTDB_ENDPOINT'], aadCredentials });44const scripts = client.database('builds').container(quality).scripts;45await (0, retry_1.retry)(() => scripts.storedProcedure('createBuild').execute('', [{ ...build, _partitionKey: '' }]));46}47main().then(() => {48console.log('Build successfully created');49process.exit(0);50}, err => {51console.error(err);52process.exit(1);53});54//# sourceMappingURL=createBuild.js.map5556