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