-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee56363
commit 8d38332
Showing
10 changed files
with
281 additions
and
240 deletions.
There are no files selected for viewing
237 changes: 131 additions & 106 deletions
237
ci/ci-test-tasks/test-and-verify-v2/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { WebApi, getPersonalAccessTokenHandler } from 'azure-devops-node-api'; | ||
import { IBuildApi } from 'azure-devops-node-api/BuildApi'; | ||
|
||
class API { | ||
public readonly tasks: string[]; | ||
|
||
private readonly projectName: string; | ||
private readonly webApi: WebApi; | ||
private buildApi: IBuildApi; | ||
|
||
constructor(argv: string[]) { | ||
const authToken = argv[2]; | ||
if (!authToken) { | ||
throw new Error('Auth token is not provided'); | ||
} | ||
const adoUrl = argv[3]; | ||
if (!adoUrl) { | ||
throw new Error('ADO url is not provided'); | ||
} | ||
this.projectName = argv[4]; | ||
if (!this.projectName) { | ||
throw new Error('Project name is not provided'); | ||
} | ||
const TaskArg = argv[5]; | ||
if (!TaskArg) { | ||
throw new Error('Task list is not provided'); | ||
} | ||
|
||
this.tasks = TaskArg.split(','); | ||
const authHandler = getPersonalAccessTokenHandler(authToken); | ||
this.webApi = new WebApi(adoUrl, authHandler); | ||
} | ||
|
||
public async getDefinitions () { | ||
const api = await this.getBuildApi(); | ||
|
||
return await api.getDefinitions(this.projectName); | ||
} | ||
|
||
public async getBuild (buildId: number) { | ||
const api = await this.getBuildApi(); | ||
|
||
return await api.getBuild(this.projectName, buildId); | ||
} | ||
|
||
public async queueBuild (definitionId: number, parameters = {}) { | ||
const api = await this.getBuildApi(); | ||
|
||
return await api.queueBuild({ | ||
definition: { id: definitionId }, | ||
parameters: JSON.stringify(parameters) | ||
}, this.projectName); | ||
} | ||
|
||
public async updateBuild (buildId: number) { | ||
const api = await this.getBuildApi(); | ||
|
||
return await api.updateBuild({}, this.projectName, buildId, true); | ||
} | ||
|
||
private async getBuildApi () { | ||
if (!this.buildApi) this.buildApi = await this.webApi.getBuildApi(); | ||
|
||
return this.buildApi; | ||
} | ||
} | ||
|
||
export const api = new API(process.argv); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.