Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: skip pipeline if it is disabled - without axios #19389

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 131 additions & 106 deletions 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.

2 changes: 1 addition & 1 deletion ci/ci-test-tasks/test-and-verify-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"build": "tsc"
},
"dependencies": {
"axios": "^1.6.2"
"azure-devops-node-api": "^12.1.0"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.2",
Expand Down
68 changes: 68 additions & 0 deletions ci/ci-test-tasks/test-and-verify-v2/src/api.ts
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 | null = null;

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);
39 changes: 0 additions & 39 deletions ci/ci-test-tasks/test-and-verify-v2/src/config.ts

This file was deleted.

1 change: 0 additions & 1 deletion ci/ci-test-tasks/test-and-verify-v2/src/constants.ts

This file was deleted.

Loading