fix: prompt user to select agent queue for AzDO pipeline config#7707
fix: prompt user to select agent queue for AzDO pipeline config#7707
Conversation
Instead of hardcoding the agent queue name to "Default", query all usable queues (filtered by ActionFilter: Use) and: - Auto-select if only one queue is available - Prompt the user to choose if multiple queues exist - Return a clear error if no queues are available This follows the same interactive Select pattern used for AzDo project selection in project.go. Fixes #4248 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the Azure DevOps pipeline configuration flow to avoid assuming a hardcoded agent queue name, improving compatibility across AzDO projects with different queue setups.
Changes:
- Query agent queues usable by the current user (
ActionFilter: Use) instead of searching for a hardcoded"Default"queue. - Add
selectAgentQueueto auto-select when only one queue exists, otherwise prompt the user to choose. - Add unit tests for agent-queue selection behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cli/azd/pkg/azdo/pipeline.go |
Reworks agent-queue lookup to list usable queues and select/prompt via a new helper. |
cli/azd/pkg/azdo/pipeline_test.go |
Adds unit tests covering empty/single/multiple queue selection scenarios. |
- Add bounds check on Select index to prevent potential panics - Add DefaultValue for no-prompt mode support Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Filter queues with nil Id in addition to nil/empty Name - Rename test to TestSelectAgentQueue (CamelCase convention) - Use strings.Contains for mock predicates to reduce brittleness - Add test for Select error wrapping Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
The ActionFilter: Use filter is the right call, and splitting selectAgentQueue from getAgentQueue makes the logic properly testable. Adding DefaultValue for --no-prompt mode and bounds checking on the index is more defensive than the sibling Select calls in project.go/repository.go - a good pattern to follow.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fix: Agent Queue Selection for AzDO Pipeline Config
Fixes #4248
Problem
azd pipeline config --provider azdofails withcould not find a default agent queue in projectbecause the queue name is hardcoded to"Default". Users with queues named differently (e.g.,"Azure Pipelines") cannot proceed.Solution
Instead of hardcoding the queue name, we now:
ActionFilter: Useto filter to queues the user has permission to useconsole.Select()to let the user pick, following the same pattern as AzDo project selection inproject.goChanges
cli/azd/pkg/azdo/pipeline.go— RefactoredgetAgentQueue()and extractedselectAgentQueue()for testabilitycli/azd/pkg/azdo/pipeline_test.go(new) — 5 test cases covering: no queues, empty queues, single auto-select, multiple queues with different selectionsTesting
go build ./...passesgolangci-lintreports 0 issues