forked from jmcneese/libnoise.js
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail project if set build number fails
- Loading branch information
1 parent
ca4d685
commit 4213e2e
Showing
2 changed files
with
36 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,43 @@ | ||
import * as azdev from 'azure-devops-node-api'; | ||
|
||
import { getBaseBuildConstants } from "../util"; | ||
import ERROR_CODES from './errorCodes'; | ||
|
||
|
||
(async () => { | ||
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}`; | ||
} | ||
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; | ||
|
||
buildDefinition.variables = { | ||
...buildDefinition.variables, | ||
VERSION: { | ||
allowOverride: false, | ||
isSecret: false, | ||
value: version, | ||
}, | ||
}; | ||
const authHandler = azdev.getPersonalAccessTokenHandler(token); | ||
const connection = new azdev.WebApi(orgUrl, authHandler); | ||
const build = await connection.getBuildApi(); | ||
const buildDefinition = await build.getDefinition(definitionId, projectName); | ||
|
||
await build.updateDefinition(buildDefinition, 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); | ||
} catch (e) { | ||
console.error(e); | ||
console.error("Failed to set build number. "); | ||
process.exit(ERROR_CODES.SET_BUILD_NUMBER_FAILED); | ||
} | ||
})(); |