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
Delete a pipeline (build definition) by ID or name. The command resolves the target (a positive integer is used directly; a string is resolved via GetDefinitions), issues a destructive DELETE against the Definitions REST 7.1 endpoint, and prints a success message on completion.
Note: The azdo CLI's pipelines delete operates on modern Pipelines / build definitions (i.e., it calls DeleteDefinition, not DeleteBuild). The legacy az pipelines build delete (which would call DeleteBuild on the Build resource) is not part of this issue — that is a separate concern tracked elsewhere (if needed).
Locked Decisions (do not re-derive)
#
Decision
Rationale
1
Use the vendored SDK build.Client.DeleteDefinition (not raw HTTP). Mock already generated at internal/mocks/build_client_mock.go:226.
Consistent with the broader pipelines group.
2
The pipeline is identified by a positional PIPELINE argument ([ORGANIZATION/]PROJECT/PIPELINE). The target segment is resolved via a new shared.ResolvePipelineDefinition helper at internal/cmd/pipelines/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 and pick the first match. Folds the previous --id flag into the positional.
Mirrors sibling leaves (#243, #257, #258). 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.
Standard cobra pattern; the 1st positional is the full target.
4
The command issues a destructive mutation; require a confirmation prompt unless --yes is supplied. On cancel return util.ErrCancel.
AGENTS.md: Confirmation for Destructive Operations. The Python extension uses Knack's built-in confirmation with the message "Are you sure you want to delete this pipeline?" — replicate the same prompt text.
5
Output: a one-line success message Pipeline {id} was deleted successfully. written to stdout (mirrors the Python pipeline_delete). JSON output is not applicable (the SDK returns error, not a result).
Mirrors Python output.
6
No new SDK client, no new helper beyond shared.ResolvePipelineDefinition, no new package beyond internal/cmd/pipelines/delete.
Mandate: minimal code.
7
Mocks for GetDefinitions and DeleteDefinition are already generated. Do not regenerate.
Verified at internal/mocks/build_client_mock.go:837 and :226.
The Target field of the parsed *Target is resolved via shared.ResolvePipelineDefinition(ctx, clientFact, args[0]).
Flags
Flag
Maps to
Notes
--yes (bool)
confirmation skip
Suppresses the destructive-operation prompt
Output Contract
On success, print to stdout:
Pipeline {id} was deleted successfully.
No JSON output path is provided (the SDK call returns no resource on success). If a user pipes through --json, the command should be a no-op for output purposes (or print null / {}). See internal/cmd/util/json_flags.go to confirm whether non-JSON-output commands support the --json flag at all; if not, do not register it.
azure-dev-ops-cli-extension/azure-dev-ops/azuredevops/azext_devops/dev/pipelines/commands.py#L78 — g.command('delete', 'pipeline_delete', confirmation='Are you sure you want to delete this pipeline?').
internal/cmd/pipelines/variablegroup/delete/delete.go — closest delete sibling (project-scoped, similar flag surface, has its own umbrella feat: Introduce azdo pipelines variable-group subgroup #117). Mirrors the modern delete pattern, including the confirmation prompt and --yes flag. The shared resolver at internal/cmd/pipelines/variablegroup/shared/resolve.go (ResolveVariableGroup) is the closest precedent for shared.ResolvePipelineDefinition.
Sub-issue of #116. Hardened spec — do not re-derive decisions. Mirrors
az pipelines deletefrom the Azure CLI and the Python implementation atazure-dev-ops-cli-extension/azure-dev-ops/azuredevops/azext_devops/dev/pipelines/pipeline.py#L141-L154.Command Description
Delete a pipeline (build definition) by ID or name. The command resolves the target (a positive integer is used directly; a string is resolved via
GetDefinitions), issues a destructiveDELETEagainst the Definitions REST 7.1 endpoint, and prints a success message on completion.Locked Decisions (do not re-derive)
build.Client.DeleteDefinition(not raw HTTP). Mock already generated atinternal/mocks/build_client_mock.go:226.pipelinesgroup.PIPELINEargument ([ORGANIZATION/]PROJECT/PIPELINE). The target segment is resolved via a newshared.ResolvePipelineDefinitionhelper atinternal/cmd/pipelines/shared/resolve.gothat mirrors Python'sget_definition_id_from_name: if it parses as a positive integer, use it directly; otherwise callbuild.Client.GetDefinitionsand pick the first match. Folds the previous--idflag into the positional.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, "pipeline target is required").--yesis supplied. On cancel returnutil.ErrCancel.Pipeline {id} was deleted successfully.written to stdout (mirrors the Pythonpipeline_delete). JSON output is not applicable (the SDK returnserror, not a result).shared.ResolvePipelineDefinition, no new package beyondinternal/cmd/pipelines/delete.GetDefinitionsandDeleteDefinitionare already generated. Do not regenerate.internal/mocks/build_client_mock.go:837and:226.Command Signature
cobra.ExactArgs(1)—args[0]→ target (viautil.ParseProjectTargetWithDefaultOrganization).Targetfield of the parsed*Targetis resolved viashared.ResolvePipelineDefinition(ctx, clientFact, args[0]).Flags
--yes(bool)Output Contract
On success, print to stdout:
No JSON output path is provided (the SDK call returns no resource on success). If a user pipes through
--json, the command should be a no-op for output purposes (or printnull/{}). Seeinternal/cmd/util/json_flags.goto confirm whether non-JSON-output commands support the--jsonflag at all; if not, do not register it.Command Wiring
internal/cmd/pipelines/deletedelete.go—NewCmd(ctx util.CmdContext) *cobra.Command+deleteOptions+runDeleteshared/resolve.go(underinternal/cmd/pipelines/shared/) —ResolvePipelineDefinition(ctx, clientFact, raw) (int, error)(positive-int fast path +GetDefinitionsfirst-match lookup)delete_test.go— table-driven gomock testsinternal/cmd/pipelines/pipelines.goto adddelete.NewCmd(ctx)as a top-level leaf (cmd.AddCommand(...)). Update theExampleblock.pipelines→delete(top-level).API Surface
Reuse the already-vendored client. No new SDK clients or mocks required.
build.Client.GetDefinitions→ for name → ID resolution.build.Client.DeleteDefinition→ Definitions - Delete (REST 7.1)build.DeleteDefinitionArgsstruct:{DefinitionId *int, Project *string}.error; success means the resource was removed.Mocks for
GetDefinitions(:837) andDeleteDefinition(:226) are already generated. No mock regeneration needed.Reference Existing Patterns
azure-dev-ops-cli-extension/azure-dev-ops/azuredevops/azext_devops/dev/pipelines/pipeline.py#L141-L154—pipeline_deletePython implementation.azure-dev-ops-cli-extension/azure-dev-ops/azuredevops/azext_devops/dev/pipelines/commands.py#L78—g.command('delete', 'pipeline_delete', confirmation='Are you sure you want to delete this pipeline?').internal/cmd/pipelines/variablegroup/delete/delete.go— closest delete sibling (project-scoped, similar flag surface, has its own umbrella feat: Introduceazdo pipelines variable-groupsubgroup #117). Mirrors the modern delete pattern, including the confirmation prompt and--yesflag. The shared resolver atinternal/cmd/pipelines/variablegroup/shared/resolve.go(ResolveVariableGroup) is the closest precedent forshared.ResolvePipelineDefinition.internal/cmd/boards/workitem/list/list_test.go:765-844—setupFakeDeps/stub*fixture.internal/mocks/build_client_mock.go:226— mock forDeleteDefinition(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/pipeline.pyazext_devops/dev/pipelines/commands.py