@elisra-devops/docgen-data-provider 1.12.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/models/tfs-data.d.ts +1 -0
- package/bin/modules/PipelinesDataProvider.d.ts +114 -3
- package/bin/modules/PipelinesDataProvider.js +206 -40
- package/bin/modules/PipelinesDataProvider.js.map +1 -1
- package/bin/modules/test/pipelineDataProvider.test.js +19 -19
- package/bin/modules/test/pipelineDataProvider.test.js.map +1 -1
- package/package.json +1 -1
- package/src/models/tfs-data.ts +1 -0
- package/src/modules/PipelinesDataProvider.ts +241 -53
- package/src/modules/test/pipelineDataProvider.test.ts +30 -47
package/bin/models/tfs-data.d.ts
CHANGED
|
@@ -4,16 +4,127 @@ export default class PipelinesDataProvider {
|
|
|
4
4
|
orgUrl: string;
|
|
5
5
|
token: string;
|
|
6
6
|
constructor(orgUrl: string, token: string);
|
|
7
|
-
findPreviousPipeline(
|
|
7
|
+
findPreviousPipeline(teamProject: string, pipelineId: string, toPipelineRunId: number, targetPipeline: any, searchPrevPipelineFromDifferentCommit: boolean, fromStage?: string): Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Determines if a pipeline run is invalid based on various conditions.
|
|
10
|
+
*
|
|
11
|
+
* @param pipelineRun - The pipeline run object to evaluate.
|
|
12
|
+
* @param toPipelineRunId - The pipeline run ID to compare against.
|
|
13
|
+
* @param fromStage - The stage from which the pipeline run originated.
|
|
14
|
+
* @returns `true` if the pipeline run is considered invalid, `false` otherwise.
|
|
15
|
+
*/
|
|
16
|
+
private isInvalidPipelineRun;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a specific stage in a pipeline run was successful.
|
|
19
|
+
*
|
|
20
|
+
* @param pipelineRun - The pipeline run object containing details of the run.
|
|
21
|
+
* @param teamProject - The name of the team project.
|
|
22
|
+
* @param fromStage - The name of the stage to check.
|
|
23
|
+
* @returns A promise that resolves to a boolean indicating whether the stage was successful.
|
|
24
|
+
*/
|
|
25
|
+
private isStageSuccessful;
|
|
26
|
+
/**
|
|
27
|
+
* Determines if two pipelines match based on their repository and version information.
|
|
28
|
+
*
|
|
29
|
+
* @param fromPipeline - The source pipeline to compare.
|
|
30
|
+
* @param targetPipeline - The target pipeline to compare against.
|
|
31
|
+
* @param searchPrevPipelineFromDifferentCommit - A flag indicating whether to search for a previous pipeline from a different commit.
|
|
32
|
+
* @returns `true` if the pipelines match based on the repository and version criteria; otherwise, `false`.
|
|
33
|
+
*/
|
|
34
|
+
private isMatchingPipeline;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves a set of pipeline resources from a given pipeline run object.
|
|
37
|
+
*
|
|
38
|
+
* @param inPipeline - The pipeline run object containing resources.
|
|
39
|
+
* @returns A promise that resolves to an array of unique pipeline resource objects.
|
|
40
|
+
*
|
|
41
|
+
* The function performs the following steps:
|
|
42
|
+
* 1. Initializes an empty set to store unique pipeline resources.
|
|
43
|
+
* 2. Checks if the input pipeline has any resources of type pipelines.
|
|
44
|
+
* 3. Iterates over each pipeline resource and processes it.
|
|
45
|
+
* 4. Fixes the URL of the pipeline resource to match the build API format.
|
|
46
|
+
* 5. Fetches the build details using the fixed URL.
|
|
47
|
+
* 6. If the build response is valid and matches the criteria, adds the pipeline resource to the set.
|
|
48
|
+
* 7. Returns an array of unique pipeline resources.
|
|
49
|
+
*
|
|
50
|
+
* The returned pipeline resource object contains the following properties:
|
|
51
|
+
* - name: The alias name of the resource pipeline.
|
|
52
|
+
* - buildId: The ID of the resource pipeline.
|
|
53
|
+
* - definitionId: The ID of the build definition.
|
|
54
|
+
* - buildNumber: The build number.
|
|
55
|
+
* - teamProject: The name of the team project.
|
|
56
|
+
* - provider: The type of repository provider.
|
|
57
|
+
*
|
|
58
|
+
* @throws Will log an error message if there is an issue fetching the pipeline resource.
|
|
59
|
+
*/
|
|
60
|
+
getPipelineResourcePipelinesFromObject(inPipeline: PipelineRun): Promise<any[] | Set<any>>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves a set of resource repositories from a given pipeline object.
|
|
63
|
+
*
|
|
64
|
+
* @param inPipeline - The pipeline run object containing resource information.
|
|
65
|
+
* @param gitDataProviderInstance - An instance of GitDataProvider to fetch repository details.
|
|
66
|
+
* @returns A promise that resolves to an array of unique resource repositories.
|
|
67
|
+
*/
|
|
8
68
|
getPipelineResourceRepositoriesFromObject(inPipeline: PipelineRun, gitDataProviderInstance: GitDataProvider): Promise<any[] | Set<any>>;
|
|
9
|
-
|
|
10
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves the details of a specific pipeline build by its build ID.
|
|
71
|
+
*
|
|
72
|
+
* @param projectName - The name of the project that contains the pipeline.
|
|
73
|
+
* @param buildId - The unique identifier of the build to retrieve.
|
|
74
|
+
* @returns A promise that resolves to the content of the build details.
|
|
75
|
+
*/
|
|
76
|
+
getPipelineBuildByBuildId(projectName: string, buildId: number): Promise<any>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the details of a specific pipeline run.
|
|
79
|
+
*
|
|
80
|
+
* @param projectName - The name of the project containing the pipeline.
|
|
81
|
+
* @param pipelineId - The ID of the pipeline.
|
|
82
|
+
* @param runId - The ID of the pipeline run.
|
|
83
|
+
* @returns A promise that resolves to the content of the pipeline run.
|
|
84
|
+
*/
|
|
85
|
+
getPipelineRunDetails(projectName: string, pipelineId: number, runId: number): Promise<PipelineRun>;
|
|
11
86
|
TriggerBuildById(projectName: string, buildDefanitionId: string, parameter: any): Promise<any>;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves an artifact by build ID from a specified project.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} projectName - The name of the project.
|
|
91
|
+
* @param {string} buildId - The ID of the build.
|
|
92
|
+
* @param {string} artifactName - The name of the artifact to retrieve.
|
|
93
|
+
* @returns {Promise<any>} A promise that resolves to the artifact data.
|
|
94
|
+
* @throws Will throw an error if the retrieval process fails.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* const artifact = await GetArtifactByBuildId('MyProject', '12345', 'MyArtifact');
|
|
98
|
+
* console.log(artifact);
|
|
99
|
+
*/
|
|
12
100
|
GetArtifactByBuildId(projectName: string, buildId: string, artifactName: string): Promise<any>;
|
|
101
|
+
/**
|
|
102
|
+
* Retrieves a release by its release ID for a given project.
|
|
103
|
+
*
|
|
104
|
+
* @param projectName - The name of the project.
|
|
105
|
+
* @param releaseId - The ID of the release to retrieve.
|
|
106
|
+
* @returns A promise that resolves to the release data.
|
|
107
|
+
*/
|
|
13
108
|
GetReleaseByReleaseId(projectName: string, releaseId: number): Promise<any>;
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves the run history of a specified pipeline within a project.
|
|
111
|
+
*
|
|
112
|
+
* @param projectName - The name of the project containing the pipeline.
|
|
113
|
+
* @param pipelineId - The ID of the pipeline to retrieve the run history for.
|
|
114
|
+
* @returns An object containing the count of successful runs and an array of successful run details.
|
|
115
|
+
* @throws Will log an error message if the pipeline run history could not be fetched.
|
|
116
|
+
*/
|
|
14
117
|
GetPipelineRunHistory(projectName: string, pipelineId: string): Promise<any>;
|
|
15
118
|
GetReleaseHistory(projectName: string, definitionId: string): Promise<any>;
|
|
16
119
|
GetAllPipelines(projectName: string): Promise<any>;
|
|
17
120
|
GetAllReleaseDefenitions(projectName: string): Promise<any>;
|
|
18
121
|
GetRecentReleaseArtifactInfo(projectName: string): Promise<any[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Get stage name
|
|
124
|
+
* @param pipelineRunId requested pipeline run id
|
|
125
|
+
* @param teamProject requested team project
|
|
126
|
+
* @param stageName stage name to search for in the pipeline
|
|
127
|
+
* @returns
|
|
128
|
+
*/
|
|
129
|
+
private getPipelineStageName;
|
|
19
130
|
}
|
|
@@ -9,48 +9,143 @@ class PipelinesDataProvider {
|
|
|
9
9
|
this.orgUrl = orgUrl;
|
|
10
10
|
this.token = token;
|
|
11
11
|
}
|
|
12
|
-
async findPreviousPipeline(
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
async findPreviousPipeline(teamProject, pipelineId, toPipelineRunId, targetPipeline, searchPrevPipelineFromDifferentCommit, fromStage = '') {
|
|
13
|
+
const pipelineRuns = await this.GetPipelineRunHistory(teamProject, pipelineId);
|
|
14
|
+
if (!pipelineRuns.value) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
15
17
|
for (const pipelineRun of pipelineRuns.value) {
|
|
16
|
-
if (pipelineRun
|
|
18
|
+
if (this.isInvalidPipelineRun(pipelineRun, toPipelineRunId, fromStage)) {
|
|
17
19
|
continue;
|
|
18
20
|
}
|
|
19
|
-
if (pipelineRun
|
|
21
|
+
if (fromStage && !(await this.isStageSuccessful(pipelineRun, teamProject, fromStage))) {
|
|
20
22
|
continue;
|
|
21
23
|
}
|
|
22
|
-
const fromPipeline = await this.
|
|
24
|
+
const fromPipeline = await this.getPipelineRunDetails(teamProject, Number(pipelineId), pipelineRun.id);
|
|
23
25
|
if (!fromPipeline.resources.repositories) {
|
|
24
26
|
continue;
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const toPipelineRepositories = toPipeline.resources.repositories;
|
|
29
|
-
logger_1.default.debug(`to pipeline repositories ${JSON.stringify(toPipelineRepositories)}`);
|
|
30
|
-
const fromPipeLineSelfRepo = '__designer_repo' in fromPipelineRepositories
|
|
31
|
-
? fromPipelineRepositories['__designer_repo']
|
|
32
|
-
: 'self' in fromPipelineRepositories
|
|
33
|
-
? fromPipelineRepositories['self']
|
|
34
|
-
: undefined;
|
|
35
|
-
const toPipeLineSelfRepo = '__designer_repo' in toPipelineRepositories
|
|
36
|
-
? toPipelineRepositories['__designer_repo']
|
|
37
|
-
: 'self' in toPipelineRepositories
|
|
38
|
-
? toPipelineRepositories['self']
|
|
39
|
-
: undefined;
|
|
40
|
-
if (fromPipeLineSelfRepo.repository.id === toPipeLineSelfRepo.repository.id &&
|
|
41
|
-
fromPipeLineSelfRepo.version === toPipeLineSelfRepo.version) {
|
|
42
|
-
if (searchPrevPipelineFromDifferentCommit) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (fromPipeLineSelfRepo.repository.id === toPipeLineSelfRepo.repository.id &&
|
|
47
|
-
fromPipeLineSelfRepo.refName !== toPipeLineSelfRepo.refName) {
|
|
48
|
-
continue;
|
|
28
|
+
if (this.isMatchingPipeline(fromPipeline, targetPipeline, searchPrevPipelineFromDifferentCommit)) {
|
|
29
|
+
return pipelineRun.id;
|
|
49
30
|
}
|
|
50
|
-
return pipelineRun.id;
|
|
51
31
|
}
|
|
52
32
|
return undefined;
|
|
53
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Determines if a pipeline run is invalid based on various conditions.
|
|
36
|
+
*
|
|
37
|
+
* @param pipelineRun - The pipeline run object to evaluate.
|
|
38
|
+
* @param toPipelineRunId - The pipeline run ID to compare against.
|
|
39
|
+
* @param fromStage - The stage from which the pipeline run originated.
|
|
40
|
+
* @returns `true` if the pipeline run is considered invalid, `false` otherwise.
|
|
41
|
+
*/
|
|
42
|
+
isInvalidPipelineRun(pipelineRun, toPipelineRunId, fromStage) {
|
|
43
|
+
return (pipelineRun.id >= toPipelineRunId ||
|
|
44
|
+
['canceled', 'failed', 'canceling'].includes(pipelineRun.result) ||
|
|
45
|
+
(pipelineRun.result === 'unknown' && !fromStage) ||
|
|
46
|
+
(pipelineRun.result !== 'succeeded' && !fromStage));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a specific stage in a pipeline run was successful.
|
|
50
|
+
*
|
|
51
|
+
* @param pipelineRun - The pipeline run object containing details of the run.
|
|
52
|
+
* @param teamProject - The name of the team project.
|
|
53
|
+
* @param fromStage - The name of the stage to check.
|
|
54
|
+
* @returns A promise that resolves to a boolean indicating whether the stage was successful.
|
|
55
|
+
*/
|
|
56
|
+
async isStageSuccessful(pipelineRun, teamProject, fromStage) {
|
|
57
|
+
const fromPipelineStage = await this.getPipelineStageName(pipelineRun, teamProject, fromStage);
|
|
58
|
+
return (fromPipelineStage && fromPipelineStage.state === 'completed' && fromPipelineStage.result === 'succeeded');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Determines if two pipelines match based on their repository and version information.
|
|
62
|
+
*
|
|
63
|
+
* @param fromPipeline - The source pipeline to compare.
|
|
64
|
+
* @param targetPipeline - The target pipeline to compare against.
|
|
65
|
+
* @param searchPrevPipelineFromDifferentCommit - A flag indicating whether to search for a previous pipeline from a different commit.
|
|
66
|
+
* @returns `true` if the pipelines match based on the repository and version criteria; otherwise, `false`.
|
|
67
|
+
*/
|
|
68
|
+
isMatchingPipeline(fromPipeline, targetPipeline, searchPrevPipelineFromDifferentCommit) {
|
|
69
|
+
const fromRepo = fromPipeline.resources.repositories[0].self || fromPipeline.resources.repositories.__designer_repo;
|
|
70
|
+
const targetRepo = targetPipeline.resources.repositories[0].self || targetPipeline.resources.repositories.__designer_repo;
|
|
71
|
+
if (fromRepo.repository.id !== targetRepo.repository.id) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (fromRepo.version === targetRepo.version) {
|
|
75
|
+
return !searchPrevPipelineFromDifferentCommit;
|
|
76
|
+
}
|
|
77
|
+
return fromRepo.refName === targetRepo.refName;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Retrieves a set of pipeline resources from a given pipeline run object.
|
|
81
|
+
*
|
|
82
|
+
* @param inPipeline - The pipeline run object containing resources.
|
|
83
|
+
* @returns A promise that resolves to an array of unique pipeline resource objects.
|
|
84
|
+
*
|
|
85
|
+
* The function performs the following steps:
|
|
86
|
+
* 1. Initializes an empty set to store unique pipeline resources.
|
|
87
|
+
* 2. Checks if the input pipeline has any resources of type pipelines.
|
|
88
|
+
* 3. Iterates over each pipeline resource and processes it.
|
|
89
|
+
* 4. Fixes the URL of the pipeline resource to match the build API format.
|
|
90
|
+
* 5. Fetches the build details using the fixed URL.
|
|
91
|
+
* 6. If the build response is valid and matches the criteria, adds the pipeline resource to the set.
|
|
92
|
+
* 7. Returns an array of unique pipeline resources.
|
|
93
|
+
*
|
|
94
|
+
* The returned pipeline resource object contains the following properties:
|
|
95
|
+
* - name: The alias name of the resource pipeline.
|
|
96
|
+
* - buildId: The ID of the resource pipeline.
|
|
97
|
+
* - definitionId: The ID of the build definition.
|
|
98
|
+
* - buildNumber: The build number.
|
|
99
|
+
* - teamProject: The name of the team project.
|
|
100
|
+
* - provider: The type of repository provider.
|
|
101
|
+
*
|
|
102
|
+
* @throws Will log an error message if there is an issue fetching the pipeline resource.
|
|
103
|
+
*/
|
|
104
|
+
async getPipelineResourcePipelinesFromObject(inPipeline) {
|
|
105
|
+
const resourcePipelines = new Set();
|
|
106
|
+
if (!inPipeline.resources.pipelines) {
|
|
107
|
+
return resourcePipelines;
|
|
108
|
+
}
|
|
109
|
+
const pipelines = inPipeline.resources.pipelines;
|
|
110
|
+
const pipelineEntries = Object.entries(pipelines);
|
|
111
|
+
await Promise.all(pipelineEntries.map(async ([resourcePipelineAlias, resource]) => {
|
|
112
|
+
const resourcePipelineObj = resource.pipeline;
|
|
113
|
+
const resourcePipelineName = resourcePipelineAlias;
|
|
114
|
+
let urlBeforeFix = resourcePipelineObj.url;
|
|
115
|
+
urlBeforeFix = urlBeforeFix.substring(0, urlBeforeFix.indexOf('?revision'));
|
|
116
|
+
const fixedUrl = urlBeforeFix.replace('/_apis/pipelines/', '/_apis/build/builds/');
|
|
117
|
+
let buildResponse;
|
|
118
|
+
try {
|
|
119
|
+
buildResponse = await tfs_1.TFSServices.getItemContent(fixedUrl, this.token, 'get');
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
logger_1.default.error(`Error fetching pipeline ${resourcePipelineName} : ${err.message}`);
|
|
123
|
+
}
|
|
124
|
+
if (buildResponse &&
|
|
125
|
+
buildResponse.definition.type === 'build' &&
|
|
126
|
+
buildResponse.repository.type === 'TfsGit') {
|
|
127
|
+
let resourcePipelineToAdd = {
|
|
128
|
+
name: resourcePipelineName,
|
|
129
|
+
buildId: resourcePipelineObj.id,
|
|
130
|
+
definitionId: buildResponse.definition.id,
|
|
131
|
+
buildNumber: buildResponse.buildNumber,
|
|
132
|
+
teamProject: buildResponse.project.name,
|
|
133
|
+
provider: buildResponse.repository.type,
|
|
134
|
+
};
|
|
135
|
+
if (!resourcePipelines.has(resourcePipelineToAdd)) {
|
|
136
|
+
resourcePipelines.add(resourcePipelineToAdd);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
return [...resourcePipelines];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Retrieves a set of resource repositories from a given pipeline object.
|
|
144
|
+
*
|
|
145
|
+
* @param inPipeline - The pipeline run object containing resource information.
|
|
146
|
+
* @param gitDataProviderInstance - An instance of GitDataProvider to fetch repository details.
|
|
147
|
+
* @returns A promise that resolves to an array of unique resource repositories.
|
|
148
|
+
*/
|
|
54
149
|
async getPipelineResourceRepositoriesFromObject(inPipeline, gitDataProviderInstance) {
|
|
55
150
|
const resourceRepositories = new Set();
|
|
56
151
|
if (!inPipeline.resources.repositories) {
|
|
@@ -75,11 +170,26 @@ class PipelinesDataProvider {
|
|
|
75
170
|
}
|
|
76
171
|
return [...resourceRepositories];
|
|
77
172
|
}
|
|
78
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Retrieves the details of a specific pipeline build by its build ID.
|
|
175
|
+
*
|
|
176
|
+
* @param projectName - The name of the project that contains the pipeline.
|
|
177
|
+
* @param buildId - The unique identifier of the build to retrieve.
|
|
178
|
+
* @returns A promise that resolves to the content of the build details.
|
|
179
|
+
*/
|
|
180
|
+
async getPipelineBuildByBuildId(projectName, buildId) {
|
|
79
181
|
let url = `${this.orgUrl}${projectName}/_apis/build/builds/${buildId}`;
|
|
80
182
|
return tfs_1.TFSServices.getItemContent(url, this.token, 'get');
|
|
81
183
|
} //GetCommitForPipeline
|
|
82
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Retrieves the details of a specific pipeline run.
|
|
186
|
+
*
|
|
187
|
+
* @param projectName - The name of the project containing the pipeline.
|
|
188
|
+
* @param pipelineId - The ID of the pipeline.
|
|
189
|
+
* @param runId - The ID of the pipeline run.
|
|
190
|
+
* @returns A promise that resolves to the content of the pipeline run.
|
|
191
|
+
*/
|
|
192
|
+
async getPipelineRunDetails(projectName, pipelineId, runId) {
|
|
83
193
|
let url = `${this.orgUrl}${projectName}/_apis/pipelines/${pipelineId}/runs/${runId}`;
|
|
84
194
|
return tfs_1.TFSServices.getItemContent(url, this.token);
|
|
85
195
|
}
|
|
@@ -95,6 +205,19 @@ class PipelinesDataProvider {
|
|
|
95
205
|
let res = await tfs_1.TFSServices.postRequest(url, this.token, 'post', data, null);
|
|
96
206
|
return res;
|
|
97
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Retrieves an artifact by build ID from a specified project.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} projectName - The name of the project.
|
|
212
|
+
* @param {string} buildId - The ID of the build.
|
|
213
|
+
* @param {string} artifactName - The name of the artifact to retrieve.
|
|
214
|
+
* @returns {Promise<any>} A promise that resolves to the artifact data.
|
|
215
|
+
* @throws Will throw an error if the retrieval process fails.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* const artifact = await GetArtifactByBuildId('MyProject', '12345', 'MyArtifact');
|
|
219
|
+
* console.log(artifact);
|
|
220
|
+
*/
|
|
98
221
|
async GetArtifactByBuildId(projectName, buildId, artifactName) {
|
|
99
222
|
try {
|
|
100
223
|
logger_1.default.info(`Get artifactory from project ${projectName},BuildId ${buildId} artifact name ${artifactName}`);
|
|
@@ -116,6 +239,13 @@ class PipelinesDataProvider {
|
|
|
116
239
|
throw new Error(String(err));
|
|
117
240
|
}
|
|
118
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Retrieves a release by its release ID for a given project.
|
|
244
|
+
*
|
|
245
|
+
* @param projectName - The name of the project.
|
|
246
|
+
* @param releaseId - The ID of the release to retrieve.
|
|
247
|
+
* @returns A promise that resolves to the release data.
|
|
248
|
+
*/
|
|
119
249
|
async GetReleaseByReleaseId(projectName, releaseId) {
|
|
120
250
|
let url = `${this.orgUrl}${projectName}/_apis/release/releases/${releaseId}`;
|
|
121
251
|
if (url.startsWith('https://dev.azure.com')) {
|
|
@@ -123,16 +253,29 @@ class PipelinesDataProvider {
|
|
|
123
253
|
}
|
|
124
254
|
return tfs_1.TFSServices.getItemContent(url, this.token, 'get', null, null);
|
|
125
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Retrieves the run history of a specified pipeline within a project.
|
|
258
|
+
*
|
|
259
|
+
* @param projectName - The name of the project containing the pipeline.
|
|
260
|
+
* @param pipelineId - The ID of the pipeline to retrieve the run history for.
|
|
261
|
+
* @returns An object containing the count of successful runs and an array of successful run details.
|
|
262
|
+
* @throws Will log an error message if the pipeline run history could not be fetched.
|
|
263
|
+
*/
|
|
126
264
|
async GetPipelineRunHistory(projectName, pipelineId) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
265
|
+
try {
|
|
266
|
+
let url = `${this.orgUrl}${projectName}/_apis/pipelines/${pipelineId}/runs`;
|
|
267
|
+
let res = await tfs_1.TFSServices.getItemContent(url, this.token, 'get', null, null);
|
|
268
|
+
//Filter successful builds only
|
|
269
|
+
let { value } = res;
|
|
270
|
+
if (value) {
|
|
271
|
+
const successfulRunHistory = value.filter((run) => run.result !== 'failed' || run.result !== 'canceled');
|
|
272
|
+
return { count: successfulRunHistory.length, value: successfulRunHistory };
|
|
273
|
+
}
|
|
274
|
+
return res;
|
|
275
|
+
}
|
|
276
|
+
catch (err) {
|
|
277
|
+
logger_1.default.error(`Could not fetch Pipeline Run History: ${err.message}`);
|
|
134
278
|
}
|
|
135
|
-
return res;
|
|
136
279
|
}
|
|
137
280
|
async GetReleaseHistory(projectName, definitionId) {
|
|
138
281
|
let url = `${this.orgUrl}${projectName}/_apis/release/releases?definitionId=${definitionId}&$top=200`;
|
|
@@ -177,6 +320,29 @@ class PipelinesDataProvider {
|
|
|
177
320
|
}
|
|
178
321
|
return artifactInfo;
|
|
179
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Get stage name
|
|
325
|
+
* @param pipelineRunId requested pipeline run id
|
|
326
|
+
* @param teamProject requested team project
|
|
327
|
+
* @param stageName stage name to search for in the pipeline
|
|
328
|
+
* @returns
|
|
329
|
+
*/
|
|
330
|
+
async getPipelineStageName(pipelineRunId, teamProject, stageName) {
|
|
331
|
+
let url = `${this.orgUrl}${teamProject}/_apis/build/builds/${pipelineRunId}/timeline?api-version=6.0`;
|
|
332
|
+
try {
|
|
333
|
+
const getPipelineLogsResponse = await tfs_1.TFSServices.getItemContent(url, this.token, 'get');
|
|
334
|
+
const { records } = getPipelineLogsResponse;
|
|
335
|
+
for (const record of records) {
|
|
336
|
+
if (record.type === 'Stage' && record.name === stageName) {
|
|
337
|
+
return record;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
catch (err) {
|
|
342
|
+
logger_1.default.error(`Error fetching pipeline ${pipelineRunId} with url ${url} : ${err.message}`);
|
|
343
|
+
return undefined;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
180
346
|
}
|
|
181
347
|
exports.default = PipelinesDataProvider;
|
|
182
348
|
//# sourceMappingURL=PipelinesDataProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PipelinesDataProvider.js","sourceRoot":"","sources":["../../src/modules/PipelinesDataProvider.ts"],"names":[],"mappings":";;AACA,wCAA6C;AAE7C,4CAAqC;AAGrC,MAAqB,qBAAqB;IAIxC,YAAY,MAAc,EAAE,KAAa;QAHzC,WAAM,GAAW,EAAE,CAAC;QACpB,UAAK,GAAW,EAAE,CAAC;QAGjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IA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AAE,OAAO,EAAE,GAAG,QAAQ,CAAC,mBAAmB,CAAC;oBAC7D,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;gBACtF,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,oBAAoB,CAAC,aAAqB,EAAE,WAAmB,EAAE,SAAiB;QAC9F,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,WAAW,uBAAuB,aAAa,2BAA2B,CAAC;QACtG,IAAI,CAAC;YACH,MAAM,uBAAuB,GAAG,MAAM,iBAAW,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAEzF,MAAM,EAAE,OAAO,EAAE,GAAG,uBAAuB,CAAC;YAC5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;oBACzD,OAAO,MAAM,CAAC;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,gBAAM,CAAC,KAAK,CAAC,2BAA2B,aAAa,aAAa,GAAG,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1F,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAjZD,wCAiZC"}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const __1 = require("../..");
|
|
4
|
-
require(
|
|
4
|
+
require('dotenv').config();
|
|
5
5
|
jest.setTimeout(60000);
|
|
6
6
|
const orgUrl = process.env.ORG_URL;
|
|
7
7
|
const token = process.env.PAT;
|
|
8
8
|
const dgDataProviderAzureDevOps = new __1.default(orgUrl, token);
|
|
9
|
-
describe(
|
|
10
|
-
test(
|
|
9
|
+
describe('pipeline module - tests', () => {
|
|
10
|
+
test('should return pipeline info', async () => {
|
|
11
11
|
let pipelinesDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
12
|
-
let json = await pipelinesDataProvider.
|
|
12
|
+
let json = await pipelinesDataProvider.getPipelineBuildByBuildId('tests', 244);
|
|
13
13
|
expect(json.id).toBe(244);
|
|
14
14
|
});
|
|
15
|
-
test(
|
|
15
|
+
test('should return Release definition', async () => {
|
|
16
16
|
let pipelinesDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
17
|
-
let json = await pipelinesDataProvider.GetReleaseByReleaseId(
|
|
17
|
+
let json = await pipelinesDataProvider.GetReleaseByReleaseId('tests', 1);
|
|
18
18
|
expect(json.id).toBe(1);
|
|
19
19
|
});
|
|
20
|
-
test(
|
|
20
|
+
test('should return OK(200) as response ', async () => {
|
|
21
21
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
22
|
-
let result = await PipelineDataProvider.TriggerBuildById(
|
|
22
|
+
let result = await PipelineDataProvider.TriggerBuildById('tests', '14', '{"test":"param1","age":"26","name":"denis" }');
|
|
23
23
|
expect(result.status).toBe(200);
|
|
24
24
|
});
|
|
25
|
-
test(
|
|
25
|
+
test('should the path to zip file as response ', async () => {
|
|
26
26
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
27
|
-
let result = await PipelineDataProvider.GetArtifactByBuildId(
|
|
28
|
-
|
|
27
|
+
let result = await PipelineDataProvider.GetArtifactByBuildId('tests', '245', //buildId
|
|
28
|
+
'_tests' //artifactName
|
|
29
29
|
);
|
|
30
30
|
expect(result).toBeDefined();
|
|
31
31
|
});
|
|
32
|
-
test(
|
|
32
|
+
test('should return pipeline run history ', async () => {
|
|
33
33
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
34
|
-
let json = await PipelineDataProvider.GetPipelineRunHistory(
|
|
34
|
+
let json = await PipelineDataProvider.GetPipelineRunHistory('tests', '14');
|
|
35
35
|
expect(json).toBeDefined();
|
|
36
36
|
});
|
|
37
|
-
test(
|
|
37
|
+
test('should return release defenition history ', async () => {
|
|
38
38
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
39
|
-
let json = await PipelineDataProvider.GetReleaseHistory(
|
|
39
|
+
let json = await PipelineDataProvider.GetReleaseHistory('tests', '1');
|
|
40
40
|
expect(json).toBeDefined();
|
|
41
41
|
});
|
|
42
|
-
test(
|
|
42
|
+
test('should return all pipelines ', async () => {
|
|
43
43
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
44
|
-
let json = await PipelineDataProvider.GetAllPipelines(
|
|
44
|
+
let json = await PipelineDataProvider.GetAllPipelines('tests');
|
|
45
45
|
expect(json).toBeDefined();
|
|
46
46
|
});
|
|
47
|
-
test(
|
|
47
|
+
test('should return all releaseDefenitions ', async () => {
|
|
48
48
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
49
|
-
let json = await PipelineDataProvider.GetAllReleaseDefenitions(
|
|
49
|
+
let json = await PipelineDataProvider.GetAllReleaseDefenitions('tests');
|
|
50
50
|
expect(json).toBeDefined();
|
|
51
51
|
});
|
|
52
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipelineDataProvider.test.js","sourceRoot":"","sources":["../../../src/modules/test/pipelineDataProvider.test.ts"],"names":[],"mappings":";;AAAA,6BAA8C;AAE9C,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;AAC3B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAEvB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;AACnC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AAE;QAC9C,IAAI,oBAAoB,GAAG,MAAM,yBAAyB,CAAC,wBAAwB,EAAE,CAAC;QACtF,IAAI,IAAI,GAAG,MAAM,oBAAoB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACvD,IAAI,oBAAoB,GAAG,MAAM,yBAAyB,CAAC,wBAAwB,EAAE,CAAC;QACtF,IAAI,IAAI,GAAG,MAAM,oBAAoB,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;QACxE,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/models/tfs-data.ts
CHANGED
|
@@ -14,65 +14,182 @@ export default class PipelinesDataProvider {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
public async findPreviousPipeline(
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
teamProject: string,
|
|
18
|
+
pipelineId: string,
|
|
19
19
|
toPipelineRunId: number,
|
|
20
|
-
|
|
21
|
-
searchPrevPipelineFromDifferentCommit: boolean
|
|
20
|
+
targetPipeline: any,
|
|
21
|
+
searchPrevPipelineFromDifferentCommit: boolean,
|
|
22
|
+
fromStage: string = ''
|
|
22
23
|
) {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const pipelineRuns = await this.GetPipelineRunHistory(teamProject, pipelineId);
|
|
25
|
+
if (!pipelineRuns.value) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
25
28
|
|
|
26
29
|
for (const pipelineRun of pipelineRuns.value) {
|
|
27
|
-
if (pipelineRun
|
|
30
|
+
if (this.isInvalidPipelineRun(pipelineRun, toPipelineRunId, fromStage)) {
|
|
28
31
|
continue;
|
|
29
32
|
}
|
|
30
|
-
|
|
33
|
+
|
|
34
|
+
if (fromStage && !(await this.isStageSuccessful(pipelineRun, teamProject, fromStage))) {
|
|
31
35
|
continue;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
const fromPipeline = await this.
|
|
38
|
+
const fromPipeline = await this.getPipelineRunDetails(teamProject, Number(pipelineId), pipelineRun.id);
|
|
35
39
|
if (!fromPipeline.resources.repositories) {
|
|
36
40
|
continue;
|
|
37
41
|
}
|
|
38
|
-
const fromPipelineRepositories = fromPipeline.resources.repositories;
|
|
39
|
-
logger.debug(`from pipeline repositories ${JSON.stringify(fromPipelineRepositories)}`);
|
|
40
|
-
const toPipelineRepositories = toPipeline.resources.repositories;
|
|
41
|
-
logger.debug(`to pipeline repositories ${JSON.stringify(toPipelineRepositories)}`);
|
|
42
|
-
|
|
43
|
-
const fromPipeLineSelfRepo =
|
|
44
|
-
'__designer_repo' in fromPipelineRepositories
|
|
45
|
-
? fromPipelineRepositories['__designer_repo']
|
|
46
|
-
: 'self' in fromPipelineRepositories
|
|
47
|
-
? fromPipelineRepositories['self']
|
|
48
|
-
: undefined;
|
|
49
|
-
const toPipeLineSelfRepo =
|
|
50
|
-
'__designer_repo' in toPipelineRepositories
|
|
51
|
-
? toPipelineRepositories['__designer_repo']
|
|
52
|
-
: 'self' in toPipelineRepositories
|
|
53
|
-
? toPipelineRepositories['self']
|
|
54
|
-
: undefined;
|
|
55
|
-
if (
|
|
56
|
-
fromPipeLineSelfRepo.repository.id === toPipeLineSelfRepo.repository.id &&
|
|
57
|
-
fromPipeLineSelfRepo.version === toPipeLineSelfRepo.version
|
|
58
|
-
) {
|
|
59
|
-
if (searchPrevPipelineFromDifferentCommit) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
42
|
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
fromPipeLineSelfRepo.refName !== toPipeLineSelfRepo.refName
|
|
67
|
-
) {
|
|
68
|
-
continue;
|
|
43
|
+
if (this.isMatchingPipeline(fromPipeline, targetPipeline, searchPrevPipelineFromDifferentCommit)) {
|
|
44
|
+
return pipelineRun.id;
|
|
69
45
|
}
|
|
70
|
-
|
|
71
|
-
return pipelineRun.id;
|
|
72
46
|
}
|
|
73
47
|
return undefined;
|
|
74
48
|
}
|
|
75
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Determines if a pipeline run is invalid based on various conditions.
|
|
52
|
+
*
|
|
53
|
+
* @param pipelineRun - The pipeline run object to evaluate.
|
|
54
|
+
* @param toPipelineRunId - The pipeline run ID to compare against.
|
|
55
|
+
* @param fromStage - The stage from which the pipeline run originated.
|
|
56
|
+
* @returns `true` if the pipeline run is considered invalid, `false` otherwise.
|
|
57
|
+
*/
|
|
58
|
+
private isInvalidPipelineRun(pipelineRun: any, toPipelineRunId: number, fromStage: string): boolean {
|
|
59
|
+
return (
|
|
60
|
+
pipelineRun.id >= toPipelineRunId ||
|
|
61
|
+
['canceled', 'failed', 'canceling'].includes(pipelineRun.result) ||
|
|
62
|
+
(pipelineRun.result === 'unknown' && !fromStage) ||
|
|
63
|
+
(pipelineRun.result !== 'succeeded' && !fromStage)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Checks if a specific stage in a pipeline run was successful.
|
|
69
|
+
*
|
|
70
|
+
* @param pipelineRun - The pipeline run object containing details of the run.
|
|
71
|
+
* @param teamProject - The name of the team project.
|
|
72
|
+
* @param fromStage - The name of the stage to check.
|
|
73
|
+
* @returns A promise that resolves to a boolean indicating whether the stage was successful.
|
|
74
|
+
*/
|
|
75
|
+
private async isStageSuccessful(
|
|
76
|
+
pipelineRun: any,
|
|
77
|
+
teamProject: string,
|
|
78
|
+
fromStage: string
|
|
79
|
+
): Promise<boolean> {
|
|
80
|
+
const fromPipelineStage = await this.getPipelineStageName(pipelineRun, teamProject, fromStage);
|
|
81
|
+
return (
|
|
82
|
+
fromPipelineStage && fromPipelineStage.state === 'completed' && fromPipelineStage.result === 'succeeded'
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Determines if two pipelines match based on their repository and version information.
|
|
88
|
+
*
|
|
89
|
+
* @param fromPipeline - The source pipeline to compare.
|
|
90
|
+
* @param targetPipeline - The target pipeline to compare against.
|
|
91
|
+
* @param searchPrevPipelineFromDifferentCommit - A flag indicating whether to search for a previous pipeline from a different commit.
|
|
92
|
+
* @returns `true` if the pipelines match based on the repository and version criteria; otherwise, `false`.
|
|
93
|
+
*/
|
|
94
|
+
private isMatchingPipeline(
|
|
95
|
+
fromPipeline: PipelineRun,
|
|
96
|
+
targetPipeline: PipelineRun,
|
|
97
|
+
searchPrevPipelineFromDifferentCommit: boolean
|
|
98
|
+
): boolean {
|
|
99
|
+
const fromRepo =
|
|
100
|
+
fromPipeline.resources.repositories[0].self || fromPipeline.resources.repositories.__designer_repo;
|
|
101
|
+
const targetRepo =
|
|
102
|
+
targetPipeline.resources.repositories[0].self || targetPipeline.resources.repositories.__designer_repo;
|
|
103
|
+
|
|
104
|
+
if (fromRepo.repository.id !== targetRepo.repository.id) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (fromRepo.version === targetRepo.version) {
|
|
109
|
+
return !searchPrevPipelineFromDifferentCommit;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return fromRepo.refName === targetRepo.refName;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Retrieves a set of pipeline resources from a given pipeline run object.
|
|
117
|
+
*
|
|
118
|
+
* @param inPipeline - The pipeline run object containing resources.
|
|
119
|
+
* @returns A promise that resolves to an array of unique pipeline resource objects.
|
|
120
|
+
*
|
|
121
|
+
* The function performs the following steps:
|
|
122
|
+
* 1. Initializes an empty set to store unique pipeline resources.
|
|
123
|
+
* 2. Checks if the input pipeline has any resources of type pipelines.
|
|
124
|
+
* 3. Iterates over each pipeline resource and processes it.
|
|
125
|
+
* 4. Fixes the URL of the pipeline resource to match the build API format.
|
|
126
|
+
* 5. Fetches the build details using the fixed URL.
|
|
127
|
+
* 6. If the build response is valid and matches the criteria, adds the pipeline resource to the set.
|
|
128
|
+
* 7. Returns an array of unique pipeline resources.
|
|
129
|
+
*
|
|
130
|
+
* The returned pipeline resource object contains the following properties:
|
|
131
|
+
* - name: The alias name of the resource pipeline.
|
|
132
|
+
* - buildId: The ID of the resource pipeline.
|
|
133
|
+
* - definitionId: The ID of the build definition.
|
|
134
|
+
* - buildNumber: The build number.
|
|
135
|
+
* - teamProject: The name of the team project.
|
|
136
|
+
* - provider: The type of repository provider.
|
|
137
|
+
*
|
|
138
|
+
* @throws Will log an error message if there is an issue fetching the pipeline resource.
|
|
139
|
+
*/
|
|
140
|
+
public async getPipelineResourcePipelinesFromObject(inPipeline: PipelineRun) {
|
|
141
|
+
const resourcePipelines: Set<any> = new Set();
|
|
142
|
+
|
|
143
|
+
if (!inPipeline.resources.pipelines) {
|
|
144
|
+
return resourcePipelines;
|
|
145
|
+
}
|
|
146
|
+
const pipelines = inPipeline.resources.pipelines;
|
|
147
|
+
|
|
148
|
+
const pipelineEntries = Object.entries(pipelines);
|
|
149
|
+
|
|
150
|
+
await Promise.all(
|
|
151
|
+
pipelineEntries.map(async ([resourcePipelineAlias, resource]) => {
|
|
152
|
+
const resourcePipelineObj = (resource as any).pipeline;
|
|
153
|
+
const resourcePipelineName = resourcePipelineAlias;
|
|
154
|
+
let urlBeforeFix = resourcePipelineObj.url;
|
|
155
|
+
urlBeforeFix = urlBeforeFix.substring(0, urlBeforeFix.indexOf('?revision'));
|
|
156
|
+
const fixedUrl = urlBeforeFix.replace('/_apis/pipelines/', '/_apis/build/builds/');
|
|
157
|
+
let buildResponse: any;
|
|
158
|
+
try {
|
|
159
|
+
buildResponse = await TFSServices.getItemContent(fixedUrl, this.token, 'get');
|
|
160
|
+
} catch (err: any) {
|
|
161
|
+
logger.error(`Error fetching pipeline ${resourcePipelineName} : ${err.message}`);
|
|
162
|
+
}
|
|
163
|
+
if (
|
|
164
|
+
buildResponse &&
|
|
165
|
+
buildResponse.definition.type === 'build' &&
|
|
166
|
+
buildResponse.repository.type === 'TfsGit'
|
|
167
|
+
) {
|
|
168
|
+
let resourcePipelineToAdd = {
|
|
169
|
+
name: resourcePipelineName,
|
|
170
|
+
buildId: resourcePipelineObj.id,
|
|
171
|
+
definitionId: buildResponse.definition.id,
|
|
172
|
+
buildNumber: buildResponse.buildNumber,
|
|
173
|
+
teamProject: buildResponse.project.name,
|
|
174
|
+
provider: buildResponse.repository.type,
|
|
175
|
+
};
|
|
176
|
+
if (!resourcePipelines.has(resourcePipelineToAdd)) {
|
|
177
|
+
resourcePipelines.add(resourcePipelineToAdd);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return [...resourcePipelines];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Retrieves a set of resource repositories from a given pipeline object.
|
|
188
|
+
*
|
|
189
|
+
* @param inPipeline - The pipeline run object containing resource information.
|
|
190
|
+
* @param gitDataProviderInstance - An instance of GitDataProvider to fetch repository details.
|
|
191
|
+
* @returns A promise that resolves to an array of unique resource repositories.
|
|
192
|
+
*/
|
|
76
193
|
public async getPipelineResourceRepositoriesFromObject(
|
|
77
194
|
inPipeline: PipelineRun,
|
|
78
195
|
gitDataProviderInstance: GitDataProvider
|
|
@@ -103,12 +220,27 @@ export default class PipelinesDataProvider {
|
|
|
103
220
|
return [...resourceRepositories];
|
|
104
221
|
}
|
|
105
222
|
|
|
106
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Retrieves the details of a specific pipeline build by its build ID.
|
|
225
|
+
*
|
|
226
|
+
* @param projectName - The name of the project that contains the pipeline.
|
|
227
|
+
* @param buildId - The unique identifier of the build to retrieve.
|
|
228
|
+
* @returns A promise that resolves to the content of the build details.
|
|
229
|
+
*/
|
|
230
|
+
async getPipelineBuildByBuildId(projectName: string, buildId: number) {
|
|
107
231
|
let url = `${this.orgUrl}${projectName}/_apis/build/builds/${buildId}`;
|
|
108
232
|
return TFSServices.getItemContent(url, this.token, 'get');
|
|
109
233
|
} //GetCommitForPipeline
|
|
110
234
|
|
|
111
|
-
|
|
235
|
+
/**
|
|
236
|
+
* Retrieves the details of a specific pipeline run.
|
|
237
|
+
*
|
|
238
|
+
* @param projectName - The name of the project containing the pipeline.
|
|
239
|
+
* @param pipelineId - The ID of the pipeline.
|
|
240
|
+
* @param runId - The ID of the pipeline run.
|
|
241
|
+
* @returns A promise that resolves to the content of the pipeline run.
|
|
242
|
+
*/
|
|
243
|
+
async getPipelineRunDetails(projectName: string, pipelineId: number, runId: number): Promise<PipelineRun> {
|
|
112
244
|
let url = `${this.orgUrl}${projectName}/_apis/pipelines/${pipelineId}/runs/${runId}`;
|
|
113
245
|
return TFSServices.getItemContent(url, this.token);
|
|
114
246
|
}
|
|
@@ -126,6 +258,19 @@ export default class PipelinesDataProvider {
|
|
|
126
258
|
return res;
|
|
127
259
|
}
|
|
128
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Retrieves an artifact by build ID from a specified project.
|
|
263
|
+
*
|
|
264
|
+
* @param {string} projectName - The name of the project.
|
|
265
|
+
* @param {string} buildId - The ID of the build.
|
|
266
|
+
* @param {string} artifactName - The name of the artifact to retrieve.
|
|
267
|
+
* @returns {Promise<any>} A promise that resolves to the artifact data.
|
|
268
|
+
* @throws Will throw an error if the retrieval process fails.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* const artifact = await GetArtifactByBuildId('MyProject', '12345', 'MyArtifact');
|
|
272
|
+
* console.log(artifact);
|
|
273
|
+
*/
|
|
129
274
|
async GetArtifactByBuildId(projectName: string, buildId: string, artifactName: string): Promise<any> {
|
|
130
275
|
try {
|
|
131
276
|
logger.info(
|
|
@@ -149,6 +294,13 @@ export default class PipelinesDataProvider {
|
|
|
149
294
|
}
|
|
150
295
|
}
|
|
151
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Retrieves a release by its release ID for a given project.
|
|
299
|
+
*
|
|
300
|
+
* @param projectName - The name of the project.
|
|
301
|
+
* @param releaseId - The ID of the release to retrieve.
|
|
302
|
+
* @returns A promise that resolves to the release data.
|
|
303
|
+
*/
|
|
152
304
|
async GetReleaseByReleaseId(projectName: string, releaseId: number): Promise<any> {
|
|
153
305
|
let url = `${this.orgUrl}${projectName}/_apis/release/releases/${releaseId}`;
|
|
154
306
|
if (url.startsWith('https://dev.azure.com')) {
|
|
@@ -157,18 +309,30 @@ export default class PipelinesDataProvider {
|
|
|
157
309
|
return TFSServices.getItemContent(url, this.token, 'get', null, null);
|
|
158
310
|
}
|
|
159
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Retrieves the run history of a specified pipeline within a project.
|
|
314
|
+
*
|
|
315
|
+
* @param projectName - The name of the project containing the pipeline.
|
|
316
|
+
* @param pipelineId - The ID of the pipeline to retrieve the run history for.
|
|
317
|
+
* @returns An object containing the count of successful runs and an array of successful run details.
|
|
318
|
+
* @throws Will log an error message if the pipeline run history could not be fetched.
|
|
319
|
+
*/
|
|
160
320
|
async GetPipelineRunHistory(projectName: string, pipelineId: string) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
321
|
+
try {
|
|
322
|
+
let url: string = `${this.orgUrl}${projectName}/_apis/pipelines/${pipelineId}/runs`;
|
|
323
|
+
let res: any = await TFSServices.getItemContent(url, this.token, 'get', null, null);
|
|
324
|
+
//Filter successful builds only
|
|
325
|
+
let { value } = res;
|
|
326
|
+
if (value) {
|
|
327
|
+
const successfulRunHistory = value.filter(
|
|
328
|
+
(run: any) => run.result !== 'failed' || run.result !== 'canceled'
|
|
329
|
+
);
|
|
330
|
+
return { count: successfulRunHistory.length, value: successfulRunHistory };
|
|
331
|
+
}
|
|
332
|
+
return res;
|
|
333
|
+
} catch (err: any) {
|
|
334
|
+
logger.error(`Could not fetch Pipeline Run History: ${err.message}`);
|
|
170
335
|
}
|
|
171
|
-
return res;
|
|
172
336
|
}
|
|
173
337
|
|
|
174
338
|
async GetReleaseHistory(projectName: string, definitionId: string) {
|
|
@@ -217,4 +381,28 @@ export default class PipelinesDataProvider {
|
|
|
217
381
|
}
|
|
218
382
|
return artifactInfo;
|
|
219
383
|
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Get stage name
|
|
387
|
+
* @param pipelineRunId requested pipeline run id
|
|
388
|
+
* @param teamProject requested team project
|
|
389
|
+
* @param stageName stage name to search for in the pipeline
|
|
390
|
+
* @returns
|
|
391
|
+
*/
|
|
392
|
+
private async getPipelineStageName(pipelineRunId: number, teamProject: string, stageName: string) {
|
|
393
|
+
let url = `${this.orgUrl}${teamProject}/_apis/build/builds/${pipelineRunId}/timeline?api-version=6.0`;
|
|
394
|
+
try {
|
|
395
|
+
const getPipelineLogsResponse = await TFSServices.getItemContent(url, this.token, 'get');
|
|
396
|
+
|
|
397
|
+
const { records } = getPipelineLogsResponse;
|
|
398
|
+
for (const record of records) {
|
|
399
|
+
if (record.type === 'Stage' && record.name === stageName) {
|
|
400
|
+
return record;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
} catch (err: any) {
|
|
404
|
+
logger.error(`Error fetching pipeline ${pipelineRunId} with url ${url} : ${err.message}`);
|
|
405
|
+
return undefined;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
220
408
|
}
|
|
@@ -1,80 +1,63 @@
|
|
|
1
|
-
import DgDataProviderAzureDevOps from
|
|
1
|
+
import DgDataProviderAzureDevOps from '../..';
|
|
2
2
|
|
|
3
|
-
require(
|
|
3
|
+
require('dotenv').config();
|
|
4
4
|
jest.setTimeout(60000);
|
|
5
5
|
|
|
6
6
|
const orgUrl = process.env.ORG_URL;
|
|
7
7
|
const token = process.env.PAT;
|
|
8
|
-
const dgDataProviderAzureDevOps = new DgDataProviderAzureDevOps(orgUrl,token);
|
|
8
|
+
const dgDataProviderAzureDevOps = new DgDataProviderAzureDevOps(orgUrl, token);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let
|
|
14
|
-
let json = await pipelinesDataProvider.getPipelineFromPipelineId(
|
|
15
|
-
"tests",
|
|
16
|
-
244
|
|
17
|
-
);
|
|
10
|
+
describe('pipeline module - tests', () => {
|
|
11
|
+
test('should return pipeline info', async () => {
|
|
12
|
+
let pipelinesDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
13
|
+
let json = await pipelinesDataProvider.getPipelineBuildByBuildId('tests', 244);
|
|
18
14
|
expect(json.id).toBe(244);
|
|
19
15
|
});
|
|
20
|
-
test(
|
|
21
|
-
let pipelinesDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider()
|
|
22
|
-
let json = await pipelinesDataProvider.GetReleaseByReleaseId(
|
|
23
|
-
"tests",
|
|
24
|
-
1
|
|
25
|
-
);
|
|
16
|
+
test('should return Release definition', async () => {
|
|
17
|
+
let pipelinesDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
18
|
+
let json = await pipelinesDataProvider.GetReleaseByReleaseId('tests', 1);
|
|
26
19
|
expect(json.id).toBe(1);
|
|
27
20
|
});
|
|
28
|
-
test(
|
|
21
|
+
test('should return OK(200) as response ', async () => {
|
|
29
22
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
30
23
|
let result = await PipelineDataProvider.TriggerBuildById(
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
'tests',
|
|
25
|
+
'14',
|
|
33
26
|
'{"test":"param1","age":"26","name":"denis" }'
|
|
34
27
|
);
|
|
35
28
|
expect(result.status).toBe(200);
|
|
36
29
|
});
|
|
37
|
-
test(
|
|
30
|
+
test('should the path to zip file as response ', async () => {
|
|
38
31
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
39
32
|
let result = await PipelineDataProvider.GetArtifactByBuildId(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
'tests',
|
|
34
|
+
'245', //buildId
|
|
35
|
+
'_tests' //artifactName
|
|
43
36
|
);
|
|
44
37
|
expect(result).toBeDefined();
|
|
45
38
|
});
|
|
46
39
|
|
|
47
|
-
test(
|
|
40
|
+
test('should return pipeline run history ', async () => {
|
|
48
41
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
49
|
-
let json = await PipelineDataProvider.GetPipelineRunHistory(
|
|
50
|
-
"tests",
|
|
51
|
-
"14"
|
|
52
|
-
);
|
|
42
|
+
let json = await PipelineDataProvider.GetPipelineRunHistory('tests', '14');
|
|
53
43
|
expect(json).toBeDefined();
|
|
54
|
-
})
|
|
44
|
+
});
|
|
55
45
|
|
|
56
|
-
test(
|
|
46
|
+
test('should return release defenition history ', async () => {
|
|
57
47
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
58
|
-
let json = await PipelineDataProvider.GetReleaseHistory(
|
|
59
|
-
"tests",
|
|
60
|
-
"1"
|
|
61
|
-
);
|
|
48
|
+
let json = await PipelineDataProvider.GetReleaseHistory('tests', '1');
|
|
62
49
|
expect(json).toBeDefined();
|
|
63
|
-
})
|
|
50
|
+
});
|
|
64
51
|
|
|
65
|
-
test(
|
|
52
|
+
test('should return all pipelines ', async () => {
|
|
66
53
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
67
|
-
let json = await PipelineDataProvider.GetAllPipelines(
|
|
68
|
-
"tests"
|
|
69
|
-
);
|
|
54
|
+
let json = await PipelineDataProvider.GetAllPipelines('tests');
|
|
70
55
|
expect(json).toBeDefined();
|
|
71
|
-
})
|
|
56
|
+
});
|
|
72
57
|
|
|
73
|
-
test(
|
|
58
|
+
test('should return all releaseDefenitions ', async () => {
|
|
74
59
|
let PipelineDataProvider = await dgDataProviderAzureDevOps.getPipelinesDataProvider();
|
|
75
|
-
let json = await PipelineDataProvider.GetAllReleaseDefenitions(
|
|
76
|
-
"tests"
|
|
77
|
-
);
|
|
60
|
+
let json = await PipelineDataProvider.GetAllReleaseDefenitions('tests');
|
|
78
61
|
expect(json).toBeDefined();
|
|
79
|
-
})
|
|
80
|
-
});
|
|
62
|
+
});
|
|
63
|
+
});
|