feat(plugins/azure-devops): support for multiple builds-definitions

Signed-off-by: Sebastian Paredero <sebaparedero14@gmail.com>
This commit is contained in:
Sebastian Paredero
2023-05-04 10:59:17 -03:00
parent 1ebb0a3944
commit 877df26108
3 changed files with 23 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-azure-devops': minor
---
The getBuildRuns function now checks contains multiple comma-separated builds and splits them to send multiple requests for each and concatenates the results.
+1 -1
View File
@@ -70,7 +70,7 @@ dev.azure.com/project: <project-name>
dev.azure.com/build-definition: <build-definition-name>
```
In this case `<project-name>` will be the name of your Team Project and `<build-definition-name>` will be the name of the Build Definition you would like to see Builds for. If the Build Definition name has spaces in it make sure to put quotes around it
In this case `<project-name>` will be the name of your Team Project and `<build-definition-name>` will be the name of the Build Definition you would like to see Builds for, and it's possible to add more Builds separated by a comma. If the Build Definition name has spaces in it make sure to put quotes around it.
### Azure Pipelines Component
@@ -120,7 +120,23 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
queryString.append('repoName', repoName);
}
if (definitionName) {
queryString.append('definitionName', definitionName);
const definitionNames = definitionName.split(',');
if (definitionNames.length > 1) {
const buildRuns: BuildRun[] = [];
for (const name of definitionNames) {
queryString.set('definitionName', name.trim());
if (options?.top) {
queryString.set('top', options.top.toString());
}
const urlSegment = `builds/${encodeURIComponent(
projectName,
)}?${queryString}`;
const items = await this.get<BuildRun[]>(urlSegment);
buildRuns.push(...items);
}
return { items: buildRuns };
}
queryString.append('definitionName', definitionName.trim());
}
if (options?.top) {
queryString.append('top', options.top.toString());