[ado2gh] RewirePipeline - Accept definitionId (int) for ado-pipeline parameter
- Dominant language
- C#
- Stars
- 478
- Forks
- 146
- Avg merge
- 7d 21h
- Merged PRs (30d)
- 2
Description
## Description
Currently, we provide the name or path of the pipeline definition (ado-pipeline) to perform the rewire.
With this value, we look for the definitionId (int) - this is expensive as it is necessary to enumerate all Definitions as the API does not provide a method for this.
```csharp
// removed code for brevity
public virtual async Task GetPipelineId(string org, string teamProject, string pipeline)
{
// Check if we have the pipeline id cached - this will gone after process kill / execution
if (_pipelineIds.TryGetValue((org.ToUpper(), teamProject.ToUpper(), pipelinePath.ToUpper()), out var result))
{
return result;
}
var url = $"{_adoBaseUrl}/{org.EscapeDataString()}/{teamProject.EscapeDataString()}/_apis/build/definitions?queryOrder=definitionNameAscending";
// expensive call
var response = await _client.GetWithPagingAsync(url);
```
To avoid this, the user could have the option to directly pass definitionId - this would avoid unnecessary calls and make the process faster.
The suggestion is to use the same parameter (ado-pipeline) and in the implementation, consider that it is the definitionId if it is a number, otherwise, follow the current process - convenient for those who do not have the definitionId at hand.
```csharp
// removed some code for brevity
public virtual async Task GetPipelineId(string org, string teamProject, string pipeline)
{
// Check if the pipeline is a number - the id itself
if (int.ParseInt(pipeline, out var definitionId)) {
return definitionId;
}
/// continue with the rest of the code
```
It makes sense? If so, I will provide a PR.
Contributor guide
Assessment
This issue has not been assessed yet.