Azure Pipelines Generator
Overview
Generate production-ready Azure DevOps Pipeline configurations following current best practices, security standards, and naming conventions. All generated resources are automatically validated using the devops-skills:azure-pipelines-validator skill to ensure syntax correctness and compliance with best practices.
Core Capabilities
1. Generate Basic CI Pipelines
Create simple continuous integration pipelines for building and testing applications.
When to use:
- User requests: "Create an Azure Pipeline for...", "Build a CI pipeline...", "Generate Azure DevOps pipeline..."
- Scenarios: Continuous integration, automated builds, automated testing
Process:
- Understand the user's requirements (language, framework, testing needs)
- Identify triggers, pool/agent requirements, and build steps
- Reference
docs/yaml-schema.md for YAML structure
- Reference
docs/best-practices.md for implementation patterns
- Reference
docs/tasks-reference.md for common tasks
- Generate the pipeline following these principles:
- Use specific vmImage versions (not 'latest')
- Pin task versions to major versions (e.g.,
@2)
- Use displayName for all stages, jobs, and important steps
- Implement caching for package managers
- Add proper test result publishing
- Use conditions appropriately
- Set reasonable timeouts
- ALWAYS validate the generated pipeline using the devops-skills:azure-pipelines-validator skill
- If validation fails, fix the issues and re-validate
Example structure:
trigger:
branches:
include:
- main
- develop
pool:
vmImage: 'ubuntu-22.04'
variables:
buildConfiguration: 'Release'
steps:
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: '20.x'
- task: Cache@2
displayName: 'Cache npm packages'
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
path: $(Pipeline.Workspace)/.npm
- script: npm ci --cache $(Pipeline.Workspace)/.npm
displayName: 'Install dependencies'
- script: npm run build
displayName: 'Build application'
- script: npm test
displayName: 'Run tests'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/test-results.xml'
2. Generate Multi-Stage CI/CD Pipelines
Create complex pipelines with multiple stages for build, test, and deployment.
When to use:
- User requests: "Create a full CI/CD pipeline...", "Build multi-stage pipeline...", "Deploy to multiple environments..."
- Scenarios: Complete CI/CD workflows, multi-environment deployments, complex build processes
Process:
- Identify all stages needed (Build, Test, Deploy)
- Determine stage dependencies and conditions
- Plan deployment strategies and environments
- Use
docs/yaml-schema.md for stage/job/step hierarchy
- Reference
examples/multi-stage-cicd.yml for patterns
- Generate pipeline with:
- Clear stage organization
- Proper
dependsOn relationships
- Deployment jobs for environment tracking
- Conditions for branch-specific deployments
- Artifact management between stages
- ALWAYS validate using devops-skills:azure-pipelines-validator skill
Example:
stages:
- stage: Build
displayName: 'Build Stage'
jobs:
- job: BuildJob
displayName: 'Build Application'
pool:
vmImage: 'ubuntu-22.04'
steps:
- script: npm run build
displayName: 'Build'
- publish: $(Build.SourcesDirectory)/dist
artifact: drop
- stage: Test
displayName: 'Test Stage'
dependsOn: Build
jobs:
- job: TestJob
displayName: 'Run Tests'
steps:
- script: npm test
displayName: 'Test'
- stage: DeployProd
displayName: 'Deploy to Production'
dependsOn: Test
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
jobs:
- deployment: DeployProd
environment: production
strategy:
runOnce:
deploy:
steps:
- script: echo "Deploying"
3. Generate Docker Build Pipelines
Create pipelines for building and pushing Docker images to container registries.
When to use:
- User requests: "Build Docker image...", "Push to container registry...", "Create Docker pipeline..."
- Scenarios: Container builds, registry pushes, multi-stage Docker builds
Process:
- Identify Docker registry (ACR, Docker Hub, etc.)
- Determine image naming and tagging strategy
- Plan for security scanning if needed
- Reference
docs/tasks-reference.md for Docker@2 task
- Reference
examples/kubernetes-deploy.yml for Docker build patterns
- Generate pipeline with:
- Docker@2 task for build and push
- Service connection for registry authentication
- Proper image tagging (build ID, latest, semantic version)
- Optional security scanning with Trivy or similar
- ALWAYS validate using devops-skills:azure-pipelines-validator skill
Example:
variables:
dockerRegistryServiceConnection: 'myACR'
imageRepository: 'myapp'
containerRegistry: 'myregistry.azurecr.io'
tag: '$(Build.BuildId)'
steps:
- task: Docker@2
displayName: 'Build and Push'
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
latest
4. Generate Kubernetes Deployment Pipelines
Create pipelines that deploy applications to Kubernetes clusters.
When to use:
- User requests: "Deploy to Kubernetes...", "Create K8s deployment pipeline...", "Deploy to AKS..."
- Scenarios: Kubernetes deployments, AKS deployments, manifest deployments
Process:
- Identify Kubernetes deployment method (kubectl, Helm, manifests)
- Determine cluster connection details
- Plan namespace and environment strategy
- Reference
docs/tasks-reference.md for Kubernetes tasks
- Reference
examples/kubernetes-deploy.yml for patterns
- Generate pipeline with:
- KubernetesManifest@0 or Kubernetes@1 tasks
- Service connection for cluster authentication
- Proper namespace management
- Rollout status checking
- Health check validation
- ALWAYS validate using devops-skills:azure-pipelines-validator skill
Example:
- task: KubernetesManifest@0
displayName: 'Deploy to Kubernetes'
inputs:
action: 'deploy'
kubernetesServiceConnection: 'myK8sCluster'
namespace: 'production'
manifests: |
k8s/deployment.yml
k8s/service.yml
containers: '$(containerRegistry)/$(imageRepository):$(tag)'
5. Generate Language-Specific Pipelines
Create pipelines optimized for specific programming languages and frameworks.
Supported Languages:
- .NET/C#: DotNetCoreCLI@2 tasks, NuGet restore, test, publish
- Node.js: NodeTool@0, Npm@1 tasks, npm ci, build, test
- Python: UsePythonVersion@0, pip install, pytest
- Java: Maven@3 or Gradle@2 tasks
- Go: GoTool@0 for version management, go build/test commands, module caching
- Docker: Multi-stage builds, layer caching
Process:
- Identify the programming language and framework
- Reference
docs/tasks-reference.md for language-specific tasks
- Reference language-specific examples (dotnet-cicd.yml, python-cicd.yml, go-cicd.yml)
- Generate pipeline with:
- Language/runtime setup tasks
- Package manager caching
- Build commands specific to framework
- Test execution with proper reporting
- Artifact publishing
- ALWAYS validate using devops-skills:azure-pipelines-validator skill
Go Language Pipeline Details
Tasks for Go:
- GoTool@0: Install specific Go version (note: @0 is the current/only major version)
- Cache@2: Cache Go modules from
$(GOPATH)/pkg/mod
- Script steps: For
go build, go test, go vet, go mod download
Go Module Caching Pattern:
- task: Cache@2
displayName: 'Cache Go modules'
inputs:
key: 'go | "$(Agent.OS)" | go.sum'
restoreKeys: |
go | "$(Agent.OS)"
path: $(GOPATH)/pkg/mod
Go Build Commands:
# Download dependencies
- script: go mod download
displayName: 'Download Go modules'
# Run linting/vetting
- script: go vet ./...
displayName: 'Run Go vet'
# Run tests with coverage
- script: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
displayName: 'Run Go tests with coverage'
# Build for Linux (common for containers)
- script: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o $(Build.ArtifactStagingDirectory)/app ./cmd/server
displayName: 'Build Go binary for Linux'
Go Matrix Testing Example:
strategy:
matrix:
go121:
goVersion: '1.21'
go122:
goVersion: '1.22'
maxParallel: 2
steps:
- task: GoTool@0
displayName: 'Install Go $(goVersion)'
inputs:
version: $(goVersion)
- script: go test -v ./...
displayName: 'Run tests'
Reference: See examples/go-cicd.yml for a complete Go CI/CD pipeline example.
6. Generate Template-Based Pipelines
Create reusable templates and pipelines that use them.
When to use:
- User requests: "Create reusable template...", "Use templates for...", "Build modular pipeline..."
- Scenarios: Template libraries, DRY configurations, shared CI/CD logic
Process:
- Identify common patterns to extract
- Design template parameters
- Reference
docs/templates-guide.md for template syntax
- Reference
examples/templates/ for template patterns
- Generate templates with:
- Clear parameter definitions with types and defaults
- Documentation comments
- Proper parameter usage with ${{ }} syntax
- Conditional logic and iteration as needed
- Generate main pipeline that uses templates
- ALWAYS validate both templates and main pipeline
Example:
# Template: templates/build.yml
parameters:
- name: nodeVersion
type: string
default: '20.x'
steps:
- task: NodeTool@0
inputs:
versionSpec: ${{ parameters.nodeVersion }}
- script: npm ci
- script: npm run build
# Main pipeline
steps:
- template: templates/build.yml
parameters:
nodeVersion: '20.x'
7. Handling Azure Pipelines Tasks and Documentation Lookup
When generating pipelines that use specific Azure Pipelines tasks or require latest documentation:
Detection:
- User mentions specific tasks (e.g., "DotNetCoreCLI", "Docker", "AzureWebApp")
- User requests integration with Azure services
- Pipeline requires specific Azure DevOps features
Process:
ALWAYS check local documentation first (REQUIRED):
Local docs are sufficient for most common tasks and should be your primary reference:
docs/tasks-reference.md - Contains .NET, Node.js, Python, Go, Docker, Kubernetes, Azure tasks
docs/yaml-schema.md - Complete YAML syntax reference
docs/best-practices.md - Security, performance, naming patterns
Most pipelines can be generated using only local docs. External lookup is only needed for:
- Tasks not documented locally (rare Azure services, third-party marketplace tasks)
- Specific version compatibility questions
- Troubleshooting specific error messages
Read relevant example files (RECOMMENDED):
Before generating, read the example file(s) that match the user's request:
- Go pipeline? → Read
examples/go-cicd.yml
- Docker/K8s? → Read
examples/kubernetes-deploy.yml
- Multi-stage? → Read
examples/multi-stage-cicd.yml
- Templates? → Read
examples/template-usage.yml
This ensures consistent patterns and best practices.
For tasks NOT in local docs, use external sources:
Option A - Context7 MCP (Preferred when available):
- Try to resolve library ID using
mcp__context7__resolve-library-id
- Query: "azure-pipelines" or "azure-devops"
- Fetch documentation using
mcp__context7__get-library-docs
- Context7 provides structured, version-aware documentation
- Best for: Complex tasks, multiple input options, detailed examples
Option B - WebSearch (Fallback or for specific queries):
Search query pattern: "[TaskName] Azure Pipelines task documentation"
Examples:
- "AzureWebApp@1 Azure Pipelines task documentation"
- "KubernetesManifest@0 Azure Pipelines task inputs"
- "Docker@2 Azure Pipelines task latest version"
- Best for: Quick lookups, specific version info, troubleshooting
When to use which:
- Use Context7 first for comprehensive task documentation
- Use WebSearch when Context7 lacks the specific task, for troubleshooting, or for quick version checks
- Either approach is acceptable - the goal is accurate, up-to-date information
Analyze documentation for:
- Task name and version (e.g.,
Docker@2)
- Required vs optional inputs
- Input types and valid values
- Task outputs if any
- Best practices and examples
- Service connection requirements
Generate pipeline using discovered information:
- Use correct task name and version
- Include all required inputs
- Use appropriate input types
- Add comments explaining task purpose
- Include service connections where needed
Include helpful comments:
# Docker@2: Build and push Docker images to a container registry
# Requires: Docker registry service connection
- task: Docker@2
displayName: 'Build and Push Docker image'
inputs:
command: buildAndPush
repository: myapp
dockerfile: Dockerfile
containerRegistry: myDockerRegistry
Example with task documentation lookup:
# Task: AzureFunctionApp@1
# Purpose: Deploy to Azure Functions
# Service Connection: Azure Resource Manager
- task: AzureFunctionApp@1
displayName: 'Deploy Azure Function'
inputs:
azureSubscription: 'AzureServiceConnection' # Required: ARM service connection
appType: 'functionAppLinux' # Linux function app
appName: 'myfunctionapp' # Function app name
package: '$(Build.ArtifactStagingDirectory)/**/*.zip' # Deployment package
runtimeStack: 'NODE|20' # Node.js 20 runtime
Validation Workflow
CRITICAL: Every generated Azure Pipeline configuration MUST be validated before presenting to the user.
Validation Process
After generating any pipeline configuration, immediately invoke the devops-skills:azure-pipelines-validator skill:
Skill: devops-skills:azure-pipelines-validator
The devops-skills:azure-pipelines-validator skill will:
- Validate YAML syntax
- Check Azure Pipelines schema compliance
- Verify task names and versions
- Check for best practices violations
- Perform security scanning (hardcoded secrets, etc.)
- Report any errors, warnings, or suggestions
If validation fails:
- Analyze the reported errors
- Fix the issues in the generated configuration
- Re-validate until all checks pass
If validation succeeds:
- Present the validated configuration to the user
- Mention that validation was successful
- Provide usage instructions
When to Skip Validation
Only skip validation when:
- Generating partial code snippets (not complete files)
- Creating examples for documentation purposes
- User explicitly requests to skip validation
Best Practices to Enforce
Reference docs/best-practices.md for comprehensive guidelines. Key principles:
Mandatory Standards
Security First:
- Never hardcode secrets or credentials
- Use service connections for external services
- Mark sensitive variables as secret in Azure DevOps
- Use specific vmImage versions (not 'latest')
- Docker image tagging strategy:
- When pushing images: Use build-specific tag as primary (e.g.,
$(Build.BuildId)), optionally add :latest for convenience
- When pulling/deploying images: Always use specific tags, never pull
:latest in production deployments
- Example: Push with
$(tag) AND latest, but deploy using $(containerRegistry)/$(imageRepository):$(tag)
Version Pinning:
- Use specific vmImage versions:
ubuntu-22.04 not ubuntu-latest
- Pin tasks to major versions:
Docker@2 not Docker@0
- Specify language/runtime versions:
'20.x' for Node.js
- Note on @0 versions: Some tasks only have @0 as their current/latest major version (e.g.,
GoTool@0, NodeTool@0, KubernetesManifest@0). Using @0 for these tasks is correct and acceptable - the goal is to use the latest available major version, not to avoid @0 specifically.
Performance:
- Implement caching for package managers (Cache@2 task)
- Use explicit
dependsOn for parallel execution
- Set artifact expiration
- Use shallow clone when full history not needed
- Optimize matrix strategies
Naming:
- Stages: PascalCase (e.g.,
BuildAndTest, DeployProduction)
- Jobs: PascalCase (e.g.,
BuildJob, TestJob)
- displayName: Sentence case (e.g.,
'Build application', 'Run tests')
- Variables: camelCase or snake_case (be consistent)
Organization:
- Use stages for complex pipelines
- Use deployment jobs for environment tracking
- Use templates for reusable logic
- Use variable groups for environment-specific variables
- Add comments for complex logic
Error Handling:
- Set timeoutInMinutes for long-running jobs
- Use conditions appropriately (succeeded(), failed(), always())
- Use continueOnError for non-critical steps
- Publish test results with
condition: succeededOrFailed()
Testing:
- Always publish test results (PublishTestResults@2)
- Publish code coverage (PublishCodeCoverageResults@1)
- Run linting as separate job or step
- Include security scanning for dependencies
Resources
Documentation (Load as Needed)
docs/yaml-schema.md - Complete Azure Pipelines YAML syntax reference
- Pipeline structure, stages, jobs, steps
- Triggers, pools, variables, parameters
- Conditions and expressions
- Use this: For YAML syntax and structure
docs/tasks-reference.md - Common Azure Pipelines tasks catalog
- .NET, Node.js, Python, Docker, Kubernetes tasks
- Task inputs, outputs, and examples
- Service connection requirements
- Use this: When selecting which task to use
docs/best-practices.md - Azure Pipelines best practices
- Security patterns, performance optimization
- Pipeline design, error handling
- Common patterns and anti-patterns
- Use this: When implementing any pipeline
docs/templates-guide.md - Templates and reusability guide
- Template types (step, job, stage, variable)
- Parameter definitions and usage
- Template expressions and iteration
- Use this: For creating reusable templates
Examples (Reference for Patterns)
IMPORTANT: When generating pipelines, explicitly read the relevant example files to ensure consistent patterns and best practices. Use the Read tool to load these files before generating.
| Example File |
When to Read |
examples/basic-ci.yml |
Simple CI pipelines, single-stage builds |
examples/multi-stage-cicd.yml |
Multi-environment deployments, complex workflows |
examples/kubernetes-deploy.yml |
Docker + K8s deployments, container builds |
examples/go-cicd.yml |
Go/Golang applications |
examples/dotnet-cicd.yml |
.NET/C# applications |
examples/python-cicd.yml |
Python applications |
examples/template-usage.yml |
Template-based pipelines |
examples/templates/build-template.yml |
Creating reusable build templates |
examples/templates/deploy-template.yml |
Creating reusable deployment templates |
Example reading workflow:
1. User requests: "Create a Go CI/CD pipeline with Docker"
2. Read: examples/go-cicd.yml (for Go patterns)
3. Read: examples/kubernetes-deploy.yml (for Docker/K8s patterns)
4. Generate pipeline combining both patterns
5. Validate with devops-skills:azure-pipelines-validator skill
Typical Workflow Example
User request: "Create a CI/CD pipeline for a Node.js app with Docker deployment to AKS"
Process:
✅ Understand requirements:
- Node.js application
- Build and test code
- Build Docker image
- Push to container registry
- Deploy to Azure Kubernetes Service
- Multiple environments (staging, production)
✅ Reference resources:
- Check
docs/yaml-schema.md for multi-stage structure
- Check
docs/tasks-reference.md for NodeTool, Docker, Kubernetes tasks
- Check
docs/best-practices.md for pipeline patterns
- Review
examples/multi-stage-cicd.yml and examples/kubernetes-deploy.yml
✅ Search for latest task documentation:
- WebSearch: "Docker@2 Azure Pipelines task"
- WebSearch: "KubernetesManifest@0 Azure Pipelines"
- Context7 (if available): Query azure-pipelines library
✅ Generate pipeline:
- Stage 1: Build Node.js application
- NodeTool@0 for Node.js setup
- npm ci with caching
- npm run build and test
- Publish test results
- Stage 2: Build Docker image
- Docker@2 buildAndPush
- Tag with Build.BuildId and latest
- Stage 3: Deploy to AKS
- Deployment job with environment
- KubernetesManifest@0 for deployment
- Health check validation
✅ Validate:
- Invoke
devops-skills:azure-pipelines-validator skill
- Fix any reported issues
- Re-validate if needed
✅ Present to user:
- Show validated pipeline
- Explain each stage
- Provide setup instructions (service connections, environments)
- Mention successful validation
Common Pipeline Patterns
Basic Three-Stage Pattern
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- script: echo "Building"
- stage: Test
dependsOn: Build
jobs:
- job: TestJob
steps:
- script: echo "Testing"
- stage: Deploy
dependsOn: Test
jobs:
- deployment: DeployJob
environment: production
strategy:
runOnce:
deploy:
steps:
- script: echo "Deploying"
Matrix Testing Pattern
strategy:
matrix:
node18:
nodeVersion: '18.x'
node20:
nodeVersion: '20.x'
node22:
nodeVersion: '22.x'
maxParallel: 3
steps:
- task: NodeTool@0
inputs:
versionSpec: $(nodeVersion)
- script: npm test
Conditional Deployment Pattern
- stage: DeployProd
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
jobs:
- deployment: DeployProd
environment: production
strategy:
runOnce:
deploy:
steps:
- script: echo "Deploy"
Error Messages and Troubleshooting
If devops-skills:azure-pipelines-validator reports errors:
- Syntax errors: Fix YAML formatting, indentation, or structure
- Task version errors: Ensure tasks use proper version format (TaskName@version)
- Pool/vmImage errors: Use specific vmImage versions, not 'latest'
- Stage/Job errors: Verify stages contain jobs, jobs contain steps
- Security warnings: Address hardcoded secrets, :latest tags
If documentation for specific task is not found:
- Try alternative search queries
- Check Microsoft Learn directly: https://learn.microsoft.com/azure/devops/pipelines/tasks/reference/
- Check GitHub: https://github.com/microsoft/azure-pipelines-tasks
- Ask user if they have specific task version requirements
Summary
Always follow this sequence when generating Azure Pipelines:
- Understand - Clarify user requirements, language, deployment targets
- Reference - Check docs/yaml-schema.md, tasks-reference.md, best-practices.md
- Search - For specific tasks, use WebSearch or Context7 for current docs
- Generate - Follow standards (pinning, caching, naming, stages)
- Validate - ALWAYS use devops-skills:azure-pipelines-validator skill
- Fix - Resolve any validation errors
- Present - Deliver validated, production-ready pipeline
Generate Azure Pipelines that are:
- ✅ Secure with proper secrets management and version pinning
- ✅ Following current best practices and conventions
- ✅ Using proper YAML structure and hierarchy
- ✅ Optimized for performance (caching, parallelization)
- ✅ Well-documented with displayName and comments
- ✅ Validated and compliant
- ✅ Production-ready and maintainable
1---2name: azure-pipelines-generator3description: Comprehensive toolkit for generating best practice Azure DevOps Pipelines following current standards and conventions. Use this skill when creating new Azure Pipelines, implementing CI/CD workflows, or building deployment pipelines.4---56# Azure Pipelines Generator78## Overview910Generate production-ready Azure DevOps Pipeline configurations following current best practices, security standards, and naming conventions. All generated resources are automatically validated using the devops-skills:azure-pipelines-validator skill to ensure syntax correctness and compliance with best practices.1112## Core Capabilities1314### 1. Generate Basic CI Pipelines1516Create simple continuous integration pipelines for building and testing applications.1718**When to use:**19- User requests: "Create an Azure Pipeline for...", "Build a CI pipeline...", "Generate Azure DevOps pipeline..."20- Scenarios: Continuous integration, automated builds, automated testing2122**Process:**231. Understand the user's requirements (language, framework, testing needs)242. Identify triggers, pool/agent requirements, and build steps253. Reference `docs/yaml-schema.md` for YAML structure264. Reference `docs/best-practices.md` for implementation patterns275. Reference `docs/tasks-reference.md` for common tasks286. Generate the pipeline following these principles:29 - Use specific vmImage versions (not 'latest')30 - Pin task versions to major versions (e.g., `@2`)31 - Use displayName for all stages, jobs, and important steps32 - Implement caching for package managers33 - Add proper test result publishing34 - Use conditions appropriately35 - Set reasonable timeouts367. **ALWAYS validate** the generated pipeline using the devops-skills:azure-pipelines-validator skill378. If validation fails, fix the issues and re-validate3839**Example structure:**40```yaml41trigger:42 branches:43 include:44 - main45 - develop4647pool:48 vmImage: 'ubuntu-22.04'4950variables:51 buildConfiguration: 'Release'5253steps:54- task: NodeTool@055 displayName: 'Install Node.js'56 inputs:57 versionSpec: '20.x'5859- task: Cache@260 displayName: 'Cache npm packages'61 inputs:62 key: 'npm | "$(Agent.OS)" | package-lock.json'63 path: $(Pipeline.Workspace)/.npm6465- script: npm ci --cache $(Pipeline.Workspace)/.npm66 displayName: 'Install dependencies'6768- script: npm run build69 displayName: 'Build application'7071- script: npm test72 displayName: 'Run tests'7374- task: PublishTestResults@275 condition: succeededOrFailed()76 inputs:77 testResultsFormat: 'JUnit'78 testResultsFiles: '**/test-results.xml'79```8081### 2. Generate Multi-Stage CI/CD Pipelines8283Create complex pipelines with multiple stages for build, test, and deployment.8485**When to use:**86- User requests: "Create a full CI/CD pipeline...", "Build multi-stage pipeline...", "Deploy to multiple environments..."87- Scenarios: Complete CI/CD workflows, multi-environment deployments, complex build processes8889**Process:**901. Identify all stages needed (Build, Test, Deploy)912. Determine stage dependencies and conditions923. Plan deployment strategies and environments934. Use `docs/yaml-schema.md` for stage/job/step hierarchy945. Reference `examples/multi-stage-cicd.yml` for patterns956. Generate pipeline with:96 - Clear stage organization97 - Proper `dependsOn` relationships98 - Deployment jobs for environment tracking99 - Conditions for branch-specific deployments100 - Artifact management between stages1017. **ALWAYS validate** using devops-skills:azure-pipelines-validator skill102103**Example:**104```yaml105stages:106- stage: Build107 displayName: 'Build Stage'108 jobs:109 - job: BuildJob110 displayName: 'Build Application'111 pool:112 vmImage: 'ubuntu-22.04'113 steps:114 - script: npm run build115 displayName: 'Build'116 - publish: $(Build.SourcesDirectory)/dist117 artifact: drop118119- stage: Test120 displayName: 'Test Stage'121 dependsOn: Build122 jobs:123 - job: TestJob124 displayName: 'Run Tests'125 steps:126 - script: npm test127 displayName: 'Test'128129- stage: DeployProd130 displayName: 'Deploy to Production'131 dependsOn: Test132 condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))133 jobs:134 - deployment: DeployProd135 environment: production136 strategy:137 runOnce:138 deploy:139 steps:140 - script: echo "Deploying"141```142143### 3. Generate Docker Build Pipelines144145Create pipelines for building and pushing Docker images to container registries.146147**When to use:**148- User requests: "Build Docker image...", "Push to container registry...", "Create Docker pipeline..."149- Scenarios: Container builds, registry pushes, multi-stage Docker builds150151**Process:**1521. Identify Docker registry (ACR, Docker Hub, etc.)1532. Determine image naming and tagging strategy1543. Plan for security scanning if needed1554. Reference `docs/tasks-reference.md` for Docker@2 task1565. Reference `examples/kubernetes-deploy.yml` for Docker build patterns1576. Generate pipeline with:158 - Docker@2 task for build and push159 - Service connection for registry authentication160 - Proper image tagging (build ID, latest, semantic version)161 - Optional security scanning with Trivy or similar1627. **ALWAYS validate** using devops-skills:azure-pipelines-validator skill163164**Example:**165```yaml166variables:167 dockerRegistryServiceConnection: 'myACR'168 imageRepository: 'myapp'169 containerRegistry: 'myregistry.azurecr.io'170 tag: '$(Build.BuildId)'171172steps:173- task: Docker@2174 displayName: 'Build and Push'175 inputs:176 command: buildAndPush177 repository: $(imageRepository)178 dockerfile: '$(Build.SourcesDirectory)/Dockerfile'179 containerRegistry: $(dockerRegistryServiceConnection)180 tags: |181 $(tag)182 latest183```184185### 4. Generate Kubernetes Deployment Pipelines186187Create pipelines that deploy applications to Kubernetes clusters.188189**When to use:**190- User requests: "Deploy to Kubernetes...", "Create K8s deployment pipeline...", "Deploy to AKS..."191- Scenarios: Kubernetes deployments, AKS deployments, manifest deployments192193**Process:**1941. Identify Kubernetes deployment method (kubectl, Helm, manifests)1952. Determine cluster connection details1963. Plan namespace and environment strategy1974. Reference `docs/tasks-reference.md` for Kubernetes tasks1985. Reference `examples/kubernetes-deploy.yml` for patterns1996. Generate pipeline with:200 - KubernetesManifest@0 or Kubernetes@1 tasks201 - Service connection for cluster authentication202 - Proper namespace management203 - Rollout status checking204 - Health check validation2057. **ALWAYS validate** using devops-skills:azure-pipelines-validator skill206207**Example:**208```yaml209- task: KubernetesManifest@0210 displayName: 'Deploy to Kubernetes'211 inputs:212 action: 'deploy'213 kubernetesServiceConnection: 'myK8sCluster'214 namespace: 'production'215 manifests: |216 k8s/deployment.yml217 k8s/service.yml218 containers: '$(containerRegistry)/$(imageRepository):$(tag)'219```220221### 5. Generate Language-Specific Pipelines222223Create pipelines optimized for specific programming languages and frameworks.224225**Supported Languages:**226- **.NET/C#**: DotNetCoreCLI@2 tasks, NuGet restore, test, publish227- **Node.js**: NodeTool@0, Npm@1 tasks, npm ci, build, test228- **Python**: UsePythonVersion@0, pip install, pytest229- **Java**: Maven@3 or Gradle@2 tasks230- **Go**: GoTool@0 for version management, go build/test commands, module caching231- **Docker**: Multi-stage builds, layer caching232233**Process:**2341. Identify the programming language and framework2352. Reference `docs/tasks-reference.md` for language-specific tasks2363. Reference language-specific examples (dotnet-cicd.yml, python-cicd.yml, go-cicd.yml)2374. Generate pipeline with:238 - Language/runtime setup tasks239 - Package manager caching240 - Build commands specific to framework241 - Test execution with proper reporting242 - Artifact publishing2435. **ALWAYS validate** using devops-skills:azure-pipelines-validator skill244245#### Go Language Pipeline Details246247**Tasks for Go:**248- **GoTool@0**: Install specific Go version (note: @0 is the current/only major version)249- **Cache@2**: Cache Go modules from `$(GOPATH)/pkg/mod`250- **Script steps**: For `go build`, `go test`, `go vet`, `go mod download`251252**Go Module Caching Pattern:**253```yaml254- task: Cache@2255 displayName: 'Cache Go modules'256 inputs:257 key: 'go | "$(Agent.OS)" | go.sum'258 restoreKeys: |259 go | "$(Agent.OS)"260 path: $(GOPATH)/pkg/mod261```262263**Go Build Commands:**264```yaml265# Download dependencies266- script: go mod download267 displayName: 'Download Go modules'268269# Run linting/vetting270- script: go vet ./...271 displayName: 'Run Go vet'272273# Run tests with coverage274- script: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...275 displayName: 'Run Go tests with coverage'276277# Build for Linux (common for containers)278- script: |279 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o $(Build.ArtifactStagingDirectory)/app ./cmd/server280 displayName: 'Build Go binary for Linux'281```282283**Go Matrix Testing Example:**284```yaml285strategy:286 matrix:287 go121:288 goVersion: '1.21'289 go122:290 goVersion: '1.22'291 maxParallel: 2292293steps:294- task: GoTool@0295 displayName: 'Install Go $(goVersion)'296 inputs:297 version: $(goVersion)298299- script: go test -v ./...300 displayName: 'Run tests'301```302303**Reference:** See `examples/go-cicd.yml` for a complete Go CI/CD pipeline example.304305### 6. Generate Template-Based Pipelines306307Create reusable templates and pipelines that use them.308309**When to use:**310- User requests: "Create reusable template...", "Use templates for...", "Build modular pipeline..."311- Scenarios: Template libraries, DRY configurations, shared CI/CD logic312313**Process:**3141. Identify common patterns to extract3152. Design template parameters3163. Reference `docs/templates-guide.md` for template syntax3174. Reference `examples/templates/` for template patterns3185. Generate templates with:319 - Clear parameter definitions with types and defaults320 - Documentation comments321 - Proper parameter usage with ${{ }} syntax322 - Conditional logic and iteration as needed3236. Generate main pipeline that uses templates3247. **ALWAYS validate** both templates and main pipeline325326**Example:**327```yaml328# Template: templates/build.yml329parameters:330- name: nodeVersion331 type: string332 default: '20.x'333334steps:335- task: NodeTool@0336 inputs:337 versionSpec: ${{ parameters.nodeVersion }}338- script: npm ci339- script: npm run build340341# Main pipeline342steps:343- template: templates/build.yml344 parameters:345 nodeVersion: '20.x'346```347348### 7. Handling Azure Pipelines Tasks and Documentation Lookup349350When generating pipelines that use specific Azure Pipelines tasks or require latest documentation:351352**Detection:**353- User mentions specific tasks (e.g., "DotNetCoreCLI", "Docker", "AzureWebApp")354- User requests integration with Azure services355- Pipeline requires specific Azure DevOps features356357**Process:**3583591. **ALWAYS check local documentation first (REQUIRED):**360 Local docs are sufficient for most common tasks and should be your primary reference:361 - `docs/tasks-reference.md` - Contains .NET, Node.js, Python, Go, Docker, Kubernetes, Azure tasks362 - `docs/yaml-schema.md` - Complete YAML syntax reference363 - `docs/best-practices.md` - Security, performance, naming patterns364365 **Most pipelines can be generated using only local docs.** External lookup is only needed for:366 - Tasks not documented locally (rare Azure services, third-party marketplace tasks)367 - Specific version compatibility questions368 - Troubleshooting specific error messages3693702. **Read relevant example files (RECOMMENDED):**371 Before generating, read the example file(s) that match the user's request:372 - Go pipeline? → Read `examples/go-cicd.yml`373 - Docker/K8s? → Read `examples/kubernetes-deploy.yml`374 - Multi-stage? → Read `examples/multi-stage-cicd.yml`375 - Templates? → Read `examples/template-usage.yml`376377 This ensures consistent patterns and best practices.3783793. **For tasks NOT in local docs, use external sources:**380381 **Option A - Context7 MCP (Preferred when available):**382 - Try to resolve library ID using `mcp__context7__resolve-library-id`383 - Query: "azure-pipelines" or "azure-devops"384 - Fetch documentation using `mcp__context7__get-library-docs`385 - Context7 provides structured, version-aware documentation386 - Best for: Complex tasks, multiple input options, detailed examples387388 **Option B - WebSearch (Fallback or for specific queries):**389 ```390 Search query pattern: "[TaskName] Azure Pipelines task documentation"391 Examples:392 - "AzureWebApp@1 Azure Pipelines task documentation"393 - "KubernetesManifest@0 Azure Pipelines task inputs"394 - "Docker@2 Azure Pipelines task latest version"395 ```396 - Best for: Quick lookups, specific version info, troubleshooting397398 **When to use which:**399 - Use Context7 first for comprehensive task documentation400 - Use WebSearch when Context7 lacks the specific task, for troubleshooting, or for quick version checks401 - Either approach is acceptable - the goal is accurate, up-to-date information4024034. **Analyze documentation for:**404 - Task name and version (e.g., `Docker@2`)405 - Required vs optional inputs406 - Input types and valid values407 - Task outputs if any408 - Best practices and examples409 - Service connection requirements4104115. **Generate pipeline using discovered information:**412 - Use correct task name and version413 - Include all required inputs414 - Use appropriate input types415 - Add comments explaining task purpose416 - Include service connections where needed4174186. **Include helpful comments:**419 ```yaml420 # Docker@2: Build and push Docker images to a container registry421 # Requires: Docker registry service connection422 - task: Docker@2423 displayName: 'Build and Push Docker image'424 inputs:425 command: buildAndPush426 repository: myapp427 dockerfile: Dockerfile428 containerRegistry: myDockerRegistry429 ```430431**Example with task documentation lookup:**432```yaml433# Task: AzureFunctionApp@1434# Purpose: Deploy to Azure Functions435# Service Connection: Azure Resource Manager436- task: AzureFunctionApp@1437 displayName: 'Deploy Azure Function'438 inputs:439 azureSubscription: 'AzureServiceConnection' # Required: ARM service connection440 appType: 'functionAppLinux' # Linux function app441 appName: 'myfunctionapp' # Function app name442 package: '$(Build.ArtifactStagingDirectory)/**/*.zip' # Deployment package443 runtimeStack: 'NODE|20' # Node.js 20 runtime444```445446## Validation Workflow447448**CRITICAL:** Every generated Azure Pipeline configuration MUST be validated before presenting to the user.449450### Validation Process4514521. **After generating any pipeline configuration**, immediately invoke the `devops-skills:azure-pipelines-validator` skill:453 ```454 Skill: devops-skills:azure-pipelines-validator455 ```4564572. **The devops-skills:azure-pipelines-validator skill will:**458 - Validate YAML syntax459 - Check Azure Pipelines schema compliance460 - Verify task names and versions461 - Check for best practices violations462 - Perform security scanning (hardcoded secrets, etc.)463 - Report any errors, warnings, or suggestions4644653. **If validation fails:**466 - Analyze the reported errors467 - Fix the issues in the generated configuration468 - Re-validate until all checks pass4694704. **If validation succeeds:**471 - Present the validated configuration to the user472 - Mention that validation was successful473 - Provide usage instructions474475### When to Skip Validation476477Only skip validation when:478- Generating partial code snippets (not complete files)479- Creating examples for documentation purposes480- User explicitly requests to skip validation481482## Best Practices to Enforce483484Reference `docs/best-practices.md` for comprehensive guidelines. Key principles:485486### Mandatory Standards4874881. **Security First:**489 - Never hardcode secrets or credentials490 - Use service connections for external services491 - Mark sensitive variables as secret in Azure DevOps492 - Use specific vmImage versions (not 'latest')493 - **Docker image tagging strategy:**494 - When **pushing** images: Use build-specific tag as primary (e.g., `$(Build.BuildId)`), optionally add `:latest` for convenience495 - When **pulling/deploying** images: Always use specific tags, never pull `:latest` in production deployments496 - Example: Push with `$(tag)` AND `latest`, but deploy using `$(containerRegistry)/$(imageRepository):$(tag)`4974982. **Version Pinning:**499 - Use specific vmImage versions: `ubuntu-22.04` not `ubuntu-latest`500 - Pin tasks to major versions: `Docker@2` not `Docker@0`501 - Specify language/runtime versions: `'20.x'` for Node.js502 - **Note on @0 versions:** Some tasks only have @0 as their current/latest major version (e.g., `GoTool@0`, `NodeTool@0`, `KubernetesManifest@0`). Using @0 for these tasks is correct and acceptable - the goal is to use the latest available major version, not to avoid @0 specifically.5035043. **Performance:**505 - Implement caching for package managers (Cache@2 task)506 - Use explicit `dependsOn` for parallel execution507 - Set artifact expiration508 - Use shallow clone when full history not needed509 - Optimize matrix strategies5105114. **Naming:**512 - Stages: PascalCase (e.g., `BuildAndTest`, `DeployProduction`)513 - Jobs: PascalCase (e.g., `BuildJob`, `TestJob`)514 - displayName: Sentence case (e.g., `'Build application'`, `'Run tests'`)515 - Variables: camelCase or snake_case (be consistent)5165175. **Organization:**518 - Use stages for complex pipelines519 - Use deployment jobs for environment tracking520 - Use templates for reusable logic521 - Use variable groups for environment-specific variables522 - Add comments for complex logic5235246. **Error Handling:**525 - Set timeoutInMinutes for long-running jobs526 - Use conditions appropriately (succeeded(), failed(), always())527 - Use continueOnError for non-critical steps528 - Publish test results with `condition: succeededOrFailed()`5295307. **Testing:**531 - Always publish test results (PublishTestResults@2)532 - Publish code coverage (PublishCodeCoverageResults@1)533 - Run linting as separate job or step534 - Include security scanning for dependencies535536## Resources537538### Documentation (Load as Needed)539540- `docs/yaml-schema.md` - Complete Azure Pipelines YAML syntax reference541 - Pipeline structure, stages, jobs, steps542 - Triggers, pools, variables, parameters543 - Conditions and expressions544 - **Use this:** For YAML syntax and structure545546- `docs/tasks-reference.md` - Common Azure Pipelines tasks catalog547 - .NET, Node.js, Python, Docker, Kubernetes tasks548 - Task inputs, outputs, and examples549 - Service connection requirements550 - **Use this:** When selecting which task to use551552- `docs/best-practices.md` - Azure Pipelines best practices553 - Security patterns, performance optimization554 - Pipeline design, error handling555 - Common patterns and anti-patterns556 - **Use this:** When implementing any pipeline557558- `docs/templates-guide.md` - Templates and reusability guide559 - Template types (step, job, stage, variable)560 - Parameter definitions and usage561 - Template expressions and iteration562 - **Use this:** For creating reusable templates563564### Examples (Reference for Patterns)565566**IMPORTANT:** When generating pipelines, **explicitly read** the relevant example files to ensure consistent patterns and best practices. Use the Read tool to load these files before generating.567568| Example File | When to Read |569|-------------|--------------|570| `examples/basic-ci.yml` | Simple CI pipelines, single-stage builds |571| `examples/multi-stage-cicd.yml` | Multi-environment deployments, complex workflows |572| `examples/kubernetes-deploy.yml` | Docker + K8s deployments, container builds |573| `examples/go-cicd.yml` | Go/Golang applications |574| `examples/dotnet-cicd.yml` | .NET/C# applications |575| `examples/python-cicd.yml` | Python applications |576| `examples/template-usage.yml` | Template-based pipelines |577| `examples/templates/build-template.yml` | Creating reusable build templates |578| `examples/templates/deploy-template.yml` | Creating reusable deployment templates |579580**Example reading workflow:**581```5821. User requests: "Create a Go CI/CD pipeline with Docker"5832. Read: examples/go-cicd.yml (for Go patterns)5843. Read: examples/kubernetes-deploy.yml (for Docker/K8s patterns)5854. Generate pipeline combining both patterns5865. Validate with devops-skills:azure-pipelines-validator skill587```588589## Typical Workflow Example590591**User request:** "Create a CI/CD pipeline for a Node.js app with Docker deployment to AKS"592593**Process:**5941. ✅ Understand requirements:595 - Node.js application596 - Build and test code597 - Build Docker image598 - Push to container registry599 - Deploy to Azure Kubernetes Service600 - Multiple environments (staging, production)6016022. ✅ Reference resources:603 - Check `docs/yaml-schema.md` for multi-stage structure604 - Check `docs/tasks-reference.md` for NodeTool, Docker, Kubernetes tasks605 - Check `docs/best-practices.md` for pipeline patterns606 - Review `examples/multi-stage-cicd.yml` and `examples/kubernetes-deploy.yml`6076083. ✅ Search for latest task documentation:609 - WebSearch: "Docker@2 Azure Pipelines task"610 - WebSearch: "KubernetesManifest@0 Azure Pipelines"611 - Context7 (if available): Query azure-pipelines library6126134. ✅ Generate pipeline:614 - Stage 1: Build Node.js application615 - NodeTool@0 for Node.js setup616 - npm ci with caching617 - npm run build and test618 - Publish test results619 - Stage 2: Build Docker image620 - Docker@2 buildAndPush621 - Tag with Build.BuildId and latest622 - Stage 3: Deploy to AKS623 - Deployment job with environment624 - KubernetesManifest@0 for deployment625 - Health check validation6266275. ✅ Validate:628 - Invoke `devops-skills:azure-pipelines-validator` skill629 - Fix any reported issues630 - Re-validate if needed6316326. ✅ Present to user:633 - Show validated pipeline634 - Explain each stage635 - Provide setup instructions (service connections, environments)636 - Mention successful validation637638## Common Pipeline Patterns639640### Basic Three-Stage Pattern641```yaml642stages:643- stage: Build644 jobs:645 - job: BuildJob646 steps:647 - script: echo "Building"648649- stage: Test650 dependsOn: Build651 jobs:652 - job: TestJob653 steps:654 - script: echo "Testing"655656- stage: Deploy657 dependsOn: Test658 jobs:659 - deployment: DeployJob660 environment: production661 strategy:662 runOnce:663 deploy:664 steps:665 - script: echo "Deploying"666```667668### Matrix Testing Pattern669```yaml670strategy:671 matrix:672 node18:673 nodeVersion: '18.x'674 node20:675 nodeVersion: '20.x'676 node22:677 nodeVersion: '22.x'678 maxParallel: 3679680steps:681- task: NodeTool@0682 inputs:683 versionSpec: $(nodeVersion)684- script: npm test685```686687### Conditional Deployment Pattern688```yaml689- stage: DeployProd690 condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))691 jobs:692 - deployment: DeployProd693 environment: production694 strategy:695 runOnce:696 deploy:697 steps:698 - script: echo "Deploy"699```700701## Error Messages and Troubleshooting702703### If devops-skills:azure-pipelines-validator reports errors:7047051. **Syntax errors:** Fix YAML formatting, indentation, or structure7062. **Task version errors:** Ensure tasks use proper version format (TaskName@version)7073. **Pool/vmImage errors:** Use specific vmImage versions, not 'latest'7084. **Stage/Job errors:** Verify stages contain jobs, jobs contain steps7095. **Security warnings:** Address hardcoded secrets, :latest tags710711### If documentation for specific task is not found:7127131. Try alternative search queries7142. Check Microsoft Learn directly: https://learn.microsoft.com/azure/devops/pipelines/tasks/reference/7153. Check GitHub: https://github.com/microsoft/azure-pipelines-tasks7164. Ask user if they have specific task version requirements717718## Summary719720Always follow this sequence when generating Azure Pipelines:7217221. **Understand** - Clarify user requirements, language, deployment targets7232. **Reference** - Check docs/yaml-schema.md, tasks-reference.md, best-practices.md7243. **Search** - For specific tasks, use WebSearch or Context7 for current docs7254. **Generate** - Follow standards (pinning, caching, naming, stages)7265. **Validate** - ALWAYS use devops-skills:azure-pipelines-validator skill7276. **Fix** - Resolve any validation errors7287. **Present** - Deliver validated, production-ready pipeline729730Generate Azure Pipelines that are:731- ✅ Secure with proper secrets management and version pinning732- ✅ Following current best practices and conventions733- ✅ Using proper YAML structure and hierarchy734- ✅ Optimized for performance (caching, parallelization)735- ✅ Well-documented with displayName and comments736- ✅ Validated and compliant737- ✅ Production-ready and maintainable