Skip to content

Commit

Permalink
Simply update build number through ##vso command
Browse files Browse the repository at this point in the history
  • Loading branch information
peabnuts123 committed Feb 10, 2019
1 parent 4213e2e commit ebed431
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 64 deletions.
40 changes: 0 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@types/rimraf": "^2.0.2",
"@types/semver": "^5.5.0",
"@types/yargs": "^12.0.8",
"azure-devops-node-api": "^7.0.0",
"chai": "^4.2.0",
"lodash": "^4.17.11",
"mocha": "^5.2.0",
Expand Down
24 changes: 1 addition & 23 deletions scripts/build/setBuildNumber.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,18 @@
import * as azdev from 'azure-devops-node-api';

import { getBaseBuildConstants } from "../util";
import ERROR_CODES from './errorCodes';


(async () => {
try {

const buildConstants = getBaseBuildConstants();
const orgUrl = "https://dev.azure.com/peabnuts123";
const token: string = process.env.AZURE_DEVOPS_TOKEN as string;
const definitionId = parseInt(process.env.SYSTEM_DEFINITIONID as string, 10);
const projectName = process.env.SYSTEM_TEAMPROJECT as string;
const branchName = process.env.BUILD_SOURCEBRANCHNAME as string;
const buildId = process.env.BUILD_BUILDID as string;

const authHandler = azdev.getPersonalAccessTokenHandler(token);
const connection = new azdev.WebApi(orgUrl, authHandler);
const build = await connection.getBuildApi();
const buildDefinition = await build.getDefinition(definitionId, projectName);

let version = buildConstants.packageJson.version;
if (branchName !== 'master') {
version += `-${branchName}b${buildId}`;
}

buildDefinition.variables = {
...buildDefinition.variables,
VERSION: {
allowOverride: false,
isSecret: false,
value: version,
},
};

await build.updateDefinition(buildDefinition, definitionId, projectName);
console.log(`##vso[build.updatebuildnumber]${version}`);
} catch (e) {
console.error(e);
console.error("Failed to set build number. ");
Expand Down

0 comments on commit ebed431

Please sign in to comment.