azure-devops-cli-extension
azure-devops-cli-extension copied to clipboard
Support Idempotent Pipeline Creation/Updates with az pipelines update --create
Is your feature request related to a problem? Please describe.
Currently I have a Makefile with a handful of az pipelines targets in it. They look something like this:
PIPELINE_NAME="Prod Environment - Deploy Platform Resources"
if az pipelines show --name "$PIPELINE_NAME" >/dev/null 2>&1; then
echo "Pipeline exists. Updating..."
az pipelines update \
--name "$PIPELINE_NAME" \
--repository PlatformInfrastructure \
--branch main \
--yml-path .azuredevops/pipelines-v2/deploy-platform-resources-prod.yaml \
--repository-type tfsgit \
--folder-path "\Platform\Infrastructure" \
--skip-first-run true
else
echo "Pipeline doesn't exist. Creating..."
az pipelines create \
--name "$PIPELINE_NAME" \
--repository PlatformInfrastructure \
--branch main \
--yml-path .azuredevops/pipelines-v2/deploy-platform-resources-prod.yaml \
--repository-type tfsgit \
--folder-path "\Platform\Infrastructure" \
--skip-first-run true
fi
This repetitive conditional logic makes automation more verbose than it needs to be. Other CLI tools like helm, kubectl, and terraform support more declarative workflows that just work regardless of the current state.
Describe the solution you'd like
There are two potential approaches that would improve the developer experience here:
Option 1: Add a new command like az pipelines apply
Introduce a new command similar to kubectl apply or helm upgrade --install:
az pipelines apply \
--name "Prod Environment - Deploy Platform Resources" \
--repository PlatformInfrastructure \
--branch main \
--yml-path .azuredevops/pipelines-v2/deploy-platform-resources-prod.yaml \
--repository-type tfsgit \
--folder-path "\Platform\Infrastructure" \
--skip-first-run true
This would:
- Create the pipeline if it doesn’t exist
- Update it if it does
Option 2: Extend az pipelines update with a --create flag
Allow az pipelines update to create the pipeline if it doesn’t exist by adding a --create flag:
az pipelines update \
--name "Prod Environment - Deploy Platform Resources" \
--repository PlatformInfrastructure \
--branch main \
--yml-path .azuredevops/pipelines-v2/deploy-platform-resources-prod.yaml \
--repository-type tfsgit \
--folder-path "\Platform\Infrastructure" \
--skip-first-run true \
--create
This would preserve compatibility with existing commands and avoid introducing a new top-level verb.
Additional context
This would significantly simplify automation in scripts and Makefiles. Supporting idempotent pipeline declarations aligns with best practices in modern infrastructure tooling and improves UX for GitOps-style workflows.