You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request (queue) a new build from a build definition identified by either ID or name. The command resolves the definition (a positive integer is used directly; a string is resolved via GetDefinitions), constructs a Build with the requested branch, commit, and (optional) variables, and posts it to the Build REST 7.1 endpoint. The returned Build is the queued build (including its new id, buildNumber, and status: notStarted | queued).
POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=7.1
Locked Decisions (do not re-derive)
#
Decision
Rationale
1
Use the vendored SDK build.Client.QueueBuild (not raw HTTP). Mock already generated at internal/mocks/build_client_mock.go:1227.
Consistent with build list (#211) and build show (#241).
2
The definition is identified by a positional DEFINITION argument ([ORGANIZATION/]PROJECT/DEFINITION). The target segment is resolved via a new shared.ResolvePipelineDefinition helper at internal/cmd/pipelines/build/queue/shared/resolve.go that mirrors Python's get_definition_id_from_name: if it parses as a positive integer, use it directly; otherwise call build.Client.GetDefinitions(name=...) and pick the first match. Folds the previous --definition-id and --definition-name flags into a single positional.
Mirrors az pipelines build queue ergonomics with one positional for either ID or name.
2.5
Parse the positional using util.ParseProjectTargetWithDefaultOrganization from internal/cmd/util/scope.go:183. The function returns a *Target with Organization, Project, Target fields, accepting 2- or 3-segment inputs.
util.ExactArgs(1, "definition target is required").
Standard cobra pattern; the 1st positional is the full target.
4
Variables are accepted via repeatable --variable flag (each name=value). Internally accumulated into a map[string]string and serialized into the Build.Parameters JSON map.
Optional flags: --branch (string, accepts main, refs/heads/main, or refs/pull/1/merge — the SDK normalizes), --commit-id (string), --queue-id (int), --open (bool) — opens the build results page in the user's default browser.
Mirrors Python build_queue parameters.
6
Default output is a table. JSON output via --json passes a dedicated view struct buildJSON (the same shape as build show (#241) uses) to opts.exporter.Write.
build.GetDefinitionsArgs struct: {Project *string, Name *string, Path *string}.
The implementation constructs a Build populated with Definition.Id, SourceBranch, SourceVersion, Parameters (from --variable), and Queue.Id (from --queue-id).
Mocks for QueueBuild (:1227) and GetDefinitions (:837) are already generated. No mock regeneration needed.
internal/cmd/pipelines/variablegroup/delete/delete.go — primary target-resolution precedent (Decision 2 / 2.5): uses Use: "delete [ORGANIZATION/]PROJECT/GROUP", util.ExactArgs(1, "..."), util.ParseProjectTargetWithDefaultOrganization, and a shared.ResolveVariableGroup helper.
internal/cmd/pipelines/build/list/list.go (feat: Implement azdo pipelines build list command #211) — primary list reference for the modern list pattern, JSON view struct, table printer, and --max-items cap. queue does not use --max-items; the table emits exactly one row.
Sub-issue of #213. Hardened spec — do not re-derive decisions. Mirrors
az pipelines build queuefrom the Azure CLI and the Python implementation atazure-dev-ops-cli-extension/azure-devops/azext_devops/dev/pipelines/build.py#L26-L75.Command Description
Request (queue) a new build from a build definition identified by either ID or name. The command resolves the definition (a positive integer is used directly; a string is resolved via
GetDefinitions), constructs aBuildwith the requested branch, commit, and (optional) variables, and posts it to the Build REST 7.1 endpoint. The returnedBuildis the queued build (including its newid,buildNumber, andstatus: notStarted | queued).Locked Decisions (do not re-derive)
build.Client.QueueBuild(not raw HTTP). Mock already generated atinternal/mocks/build_client_mock.go:1227.build list(#211) andbuild show(#241).DEFINITIONargument ([ORGANIZATION/]PROJECT/DEFINITION). The target segment is resolved via a newshared.ResolvePipelineDefinitionhelper atinternal/cmd/pipelines/build/queue/shared/resolve.gothat mirrors Python'sget_definition_id_from_name: if it parses as a positive integer, use it directly; otherwise callbuild.Client.GetDefinitions(name=...)and pick the first match. Folds the previous--definition-idand--definition-nameflags into a single positional.az pipelines build queueergonomics with one positional for either ID or name.util.ParseProjectTargetWithDefaultOrganizationfrominternal/cmd/util/scope.go:183. The function returns a*TargetwithOrganization,Project,Targetfields, accepting 2- or 3-segment inputs.internal/cmd/pipelines/variablegroup/{create,delete,show,update}/precedent.util.ExactArgs(1, "definition target is required").--variableflag (eachname=value). Internally accumulated into amap[string]stringand serialized into theBuild.ParametersJSON map.--branch(string, acceptsmain,refs/heads/main, orrefs/pull/1/merge— the SDK normalizes),--commit-id(string),--queue-id(int),--open(bool) — opens the build results page in the user's default browser.build_queueparameters.--jsonpasses a dedicated view structbuildJSON(the same shape asbuild show(#241) uses) toopts.exporter.Write.internal/cmd/pipelines/build/list/list.go(#211).shared.ResolvePipelineDefinition, no new package beyondinternal/cmd/pipelines/build/queue.QueueBuildandGetDefinitionsare already generated. Do not regenerate.internal/mocks/build_client_mock.go:1227and:837.Command Signature
cobra.ExactArgs(1)—args[0]→ target (viautil.ParseProjectTargetWithDefaultOrganization).Targetfield of the parsed*Targetis resolved viashared.ResolvePipelineDefinition(ctx, clientFact, args[0]).Flags
--branch(str)Build.SourceBranchrefs/heads/if absent--commit-id(str)Build.SourceVersion--variable(str, repeatable)Build.Parameters(JSON map)name=valueper occurrence--queue-id(int)Build.Queue.Id--open(bool)--json/--jq/--templateutil.AddJSONFlagsJSON Output Contract
The JSON view struct mirrors
build show(#241). Fields (matching SDK struct JSON tags):Table Output Contract
Default columns:
ID, NUMBER, STATUS, RESULT, DEFINITION ID, DEFINITION NAME, SOURCE BRANCH, QUEUED TIME, REASON(mirrorstransform_build_table_outputfrom_format.py).Command Wiring
internal/cmd/pipelines/build/queuequeue.go—NewCmd(ctx util.CmdContext) *cobra.Command+queueOptions+runQueueshared/resolve.go—ResolvePipelineDefinition(ctx, clientFact, raw) (int, error)(positive-int fast path +GetDefinitionsfirst-match lookup)queue_test.go— table-driven gomock testsinternal/cmd/pipelines/build/build.goto addqueue.NewCmd(ctx)tocmd.AddCommand(...). Update theExampleblock.pipelines→build→queue.API Surface
Reuse the already-vendored client. No new SDK clients or mocks required.
build.Client.GetDefinitions→ Definitions - List (REST 7.1) — for name → ID resolution.build.Client.QueueBuild→ Builds - Queue (REST 7.1)build.QueueBuildArgsstruct:{Build *Build, Project *string}.build.GetDefinitionsArgsstruct:{Project *string, Name *string, Path *string}.Buildpopulated withDefinition.Id,SourceBranch,SourceVersion,Parameters(from--variable), andQueue.Id(from--queue-id).Mocks for
QueueBuild(:1227) andGetDefinitions(:837) are already generated. No mock regeneration needed.Reference Existing Patterns
azure-dev-ops-cli-extension/azure-dev-ops/azuredevops/azext_devops/dev/pipelines/build.py#L26-L75—build_queuePython implementation.azure-dev-ops-cli-extension/azure-dev-ops/azuredevops/azext_devops/dev/pipelines/commands.py#L91—g.command('queue', 'build_queue', table_transformer=transform_build_table_output).azure-dev-ops-cli-extension/azure-dev-ops/azuredevops/azext_devops/dev/pipelines/_format.py—transform_build_table_output(single-row) and_transform_build_row(row builder).azure-dev-ops-cli-extension/azure-dev-ops/azuredevops/azext_devops/dev/pipelines/build_definition.py—get_definition_id_from_namehelper (the name → ID resolution pattern).internal/cmd/pipelines/variablegroup/delete/delete.go— primary target-resolution precedent (Decision 2 / 2.5): usesUse: "delete [ORGANIZATION/]PROJECT/GROUP",util.ExactArgs(1, "..."),util.ParseProjectTargetWithDefaultOrganization, and ashared.ResolveVariableGrouphelper.internal/cmd/pipelines/build/list/list.go(feat: Implementazdo pipelines build listcommand #211) — primary list reference for the modern list pattern, JSON view struct, table printer, and--max-itemscap.queuedoes not use--max-items; the table emits exactly one row.internal/cmd/pipelines/build/show/show.go(feat: Implementazdo pipelines build showcommand #241) — primary show sibling; reuse the samebuildJSONview struct.internal/cmd/boards/workitem/list/list_test.go:765-844—setupFakeDeps/stub*fixture.internal/mocks/build_client_mock.go:1227— mock forQueueBuild(already generated).internal/mocks/build_client_mock.go:837— mock forGetDefinitions(already generated, used for name → ID resolution).internal/azdo/factory.go:61—ClientFactory().Build(...)accessor (reuse).internal/cmd/util/scope.go:183—util.ParseProjectTargetWithDefaultOrganization(project-scoped parser).References
azext_devops/dev/pipelines/build.pyazext_devops/dev/pipelines/commands.pyazext_devops/dev/pipelines/_format.py