-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.ts
More file actions
49 lines (41 loc) · 1.26 KB
/
index.ts
File metadata and controls
49 lines (41 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Copyright (c) Trainline Limited, 2020. All rights reserved.
* See LICENSE.md in the project root for license information.
*/
import axios, { AxiosResponse } from 'axios';
import BaseDataSource, { DataSource, DataSourceBranchType } from '../BaseDataSource';
import { Stats } from '../../types';
export interface TeamCityDataSourceConfiguration {
serverUrl: string;
username: string;
password: string;
buildType: string;
fileName?: string;
}
export default class TeamCityDataSource extends BaseDataSource implements DataSource {
readonly options: TeamCityDataSourceConfiguration;
constructor(options: TeamCityDataSourceConfiguration) {
super();
this.options = options;
}
async getCompilationStats(_branchType: DataSourceBranchType, sha: string): Promise<Stats> {
const {
serverUrl,
username,
password,
buildType,
fileName = 'compilation-stats.json',
} = this.options;
const { data } = await axios.get<unknown, AxiosResponse<Stats>>(
`${serverUrl}/app/rest/builds/buildType:${buildType},branch:default:any,revision:${sha}/artifacts/content/${fileName}`,
{
auth: {
username,
password,
},
}
);
this.validateCompilationStats(data);
return data;
}
}