DevOps help for Cloud Platform Engineers
  • Welcome!
  • Quick Start Guide
  • About Me
  • CV
  • Contribute
  • 🧠DevOps & SRE Foundations
    • DevOps Overview
      • Engineering Fundamentals
      • Implementing DevOps Strategy
      • DevOps Readiness Assessment
      • Lifecycle Management
      • The 12 Factor App
      • Design for Self Healing
      • Incident Management Best Practices (2025)
    • SRE Fundamentals
      • Toil Reduction
      • System Simplicity
      • Real-world Scenarios
        • AWS VM Log Monitoring API
    • Agile Development
      • Team Agreements
        • Definition of Done
        • Definition of Ready
        • Team Manifesto
        • Working Agreement
    • Industry Scenarios
      • Finance and Banking
      • Public Sector (UK/EU)
      • Energy Sector Edge Computing
  • DevOps Practices
    • Platform Engineering
    • FinOps
    • Observability
      • Modern Practices
  • 🚀Modern DevOps Practices
    • Infrastructure Testing
    • Modern Development
    • Database DevOps
  • 🛠️Infrastructure as Code (IaC)
    • Terraform
      • Cloud Integrations - Provider-specific implementations
        • Azure Scenarios
          • Azure Authetication
            • Service Principal
            • Service Principal in block
            • Service Principal in env
        • AWS Scenarios
          • AWS Authentication
        • GCP Scenarios
          • GCP Authentication
      • Testing and Validation
        • Unit Testing
        • Integration Testing
        • End-to-End Testing
        • Terratest Guide
      • Best Practices
        • State Management
        • Security
        • Code Organization
        • Performance
      • Tools & Utilities - Enhancing the Terraform workflow
        • Terraform Docs
        • TFLint
        • Checkov
        • Terrascan
      • CI/CD Integration - Automating infrastructure deployment
        • GitHub Actions
        • Azure Pipelines
        • GitLab CI
    • Bicep
      • Getting Started - First steps with Bicep [BEGINNER]
      • Template Specs
      • Best Practices - Guidelines for effective Bicep implementations
      • Modules - Building reusable components [INTERMEDIATE]
      • Examples - Sample implementations for common scenarios
      • Advanced Features
      • CI/CD Integration - Automating Bicep deployments
        • GitHub Actions
        • Azure Pipelines
  • 💰Cost Management & FinOps
    • Cloud Cost Optimization
  • 🐳Containers & Orchestration
    • Containerization Overview
      • Docker
        • Dockerfile Best Practices
        • Docker Compose
      • Kubernetes
        • CLI Tools - Essential command-line utilities
          • Kubectl
          • Kubens
          • Kubectx
        • Core Concepts
        • Components
        • Best Practices
          • Pod Security
          • Security Monitoring
          • Resource Limits
        • Advanced Features - Beyond the basics [ADVANCED]
          • Service Mesh
            • Istio
            • Linkerd
          • Ingress Controllers
            • NGINX
            • Traefik
            • Kong
            • Gloo Edge
            • Contour
        • Tips
          • Status in Pods
          • Resource handling
          • Pod Troubleshooting Commands
        • Enterprise Architecture
        • Health Management
        • Security & Compliance
        • Virtual Clusters
      • OpenShift
  • Service Mesh & Networking
    • Service Mesh Implementation
  • Architecture Patterns
    • Data Mesh
    • Multi-Cloud Networking
    • Disaster Recovery
    • Chaos Engineering
  • Edge Computing
    • Implementation Guide
      • Serverless Edge
      • IoT Edge Patterns
      • Real-Time Processing
      • Edge AI/ML
      • Security Hardening
      • Observability Patterns
      • Network Optimization
      • Storage Patterns
  • 🔄CI/CD & GitOps
    • CI/CD Overview
      • Continuous Integration
      • Continuous Delivery
        • Deployment Strategies
        • Secrets Management
        • Blue-Green Deployments
        • Deployment Metrics
        • Progressive Delivery
        • Release Management for DevOps/SRE (2025)
      • CI/CD Platforms - Tool selection and implementation
        • Azure DevOps
          • Pipelines
            • Stages
            • Jobs
            • Steps
            • Templates - Reusable pipeline components
            • Extends
            • Service Connections - External service authentication
            • Best Practices for 2025
            • Agents and Runners
            • Third-Party Integrations
            • Azure DevOps CLI
          • Boards & Work Items
        • GitHub Actions
        • GitLab
          • GitLab Runner
          • Real-life scenarios
          • Installation guides
          • Pros and Cons
          • Comparison with alternatives
      • GitOps
        • Modern GitOps Practices
        • GitOps Patterns for Multi-Cloud (2025)
        • Flux
          • Overview
          • Progressive Delivery
          • Use GitOps with Flux, GitHub and AKS
  • Source Control
    • Source Control Overview
      • Git Branching Strategies
      • Component Versioning
      • Kubernetes Manifest Versioning
      • GitLab
      • Creating a Fork
      • Naming Branches
      • Pull Requests
      • Integrating LLMs into Source Control Workflows
  • ☁️Cloud Platforms
    • Cloud Strategy
      • AWS to Azure
      • Azure to AWS
      • GCP to Azure
      • AWS to GCP
      • GCP to AWS
    • Azure
      • Best Practices
        • Azure Best Practices Overview
        • Azure Architecture Best Practices
        • Azure Naming Standards
        • Azure Tags
        • Azure Security Best Practices
      • Landing Zones
      • Services
        • Azure Active Directory (AAD)
        • Azure Monitor
        • Azure Key Vault
        • Azure Service Bus
        • Azure DNS
        • Azure App Service
        • Azure Batch
        • Azure Machine Learning
        • Azure OpenAI Service
        • Azure Cognitive Services
        • Azure Kubernetes Service (AKS)
        • Azure Databricks
        • Azure SQL Database
      • Monitoring
      • Administration Tools - Platform management interfaces
        • Azure PowerShell
        • Azure CLI
      • Tips & Tricks
    • AWS
      • Authentication
      • Best Practices
      • Tips & Tricks
      • Services
        • AWS IAM (Identity and Access Management)
        • Amazon CloudWatch
        • Amazon SNS (Simple Notification Service)
        • Amazon SQS (Simple Queue Service)
        • Amazon Route 53
        • AWS Elastic Beanstalk
        • AWS Batch
        • Amazon SageMaker
        • Amazon Bedrock
        • Amazon Comprehend
    • Google Cloud
      • Services
        • Cloud CDN
        • Cloud DNS
        • Cloud Load Balancing
        • Google Kubernetes Engine (GKE)
        • Cloud Run
        • Artifact Registry
        • Compute Engine
        • Cloud Functions
        • App Engine
        • Cloud Storage
        • Persistent Disk
        • Filestore
        • Cloud SQL
        • Cloud Spanner
        • Firestore
        • Bigtable
        • BigQuery
        • VPC (Virtual Private Cloud)
  • 🔐Security & Compliance
    • DevSecOps Overview
      • DevSecOps Pipeline Security
      • DevSecOps
        • Real-life Examples
        • Scanning & Protection - Automated security tooling
          • Dependency Scanning
          • Credential Scanning
          • Container Security Scanning
          • Static Code Analysis
            • Best Practices
            • Tool Integration Guide
            • Pipeline Configuration
        • CI/CD Security
        • Secrets Rotation
      • Supply Chain Security
        • SLSA Framework
        • Binary Authorization
        • Artifact Signing
      • Security Best Practices
        • Threat Modeling
        • Kubernetes Security
      • SecOps
      • Zero Trust Model
      • Cloud Compliance
        • ISO/IEC 27001:2022
        • ISO 22301:2019
        • PCI DSS
        • CSA STAR
      • Security Frameworks
      • SIEM and SOAR
  • Security Architecture
    • Zero Trust Implementation
      • Identity Management
      • Network Security
      • Access Control
  • 🔍Observability & Monitoring
    • Observability Fundamentals
      • Logging
      • Metrics
      • Tracing
      • Dashboards
      • SLOs and SLAs
      • Observability as Code
      • Pipeline Observability
  • 🧪Testing Strategies
    • Testing Overview
      • Modern Testing Approaches
      • End-to-End Testing
      • Unit Testing
      • Performance Testing
        • Load Testing
      • Fault Injection Testing
      • Integration Testing
      • Smoke Testing
  • 🤖AI Integration
    • AIops Overview
      • Workflow Automation
      • Predictive Analytics
      • Code Quality
  • 🧠AI & LLM Integration
    • Overview
      • Claude
        • Installation Guide
        • Project Guides
        • MCP Server Setup
        • LLM Comparison
      • Ollama
        • Installation Guide
        • Configuration
        • Models and Fine-tuning
        • DevOps Usage
        • Docker Setup
        • GPU Setup
        • Open WebUI
      • Copilot
        • Installation Guide
        • VS Code Integration
        • CLI Usage
      • Gemini
        • Installation Guides - Platform-specific setup
          • Linux Installation
          • WSL Installation
          • NixOS Installation
        • Gemini 2.5 Features
        • Roles and Agents
        • NotebookML Guide
        • Cloud Infrastructure Deployment
        • Summary
  • 💻Development Environment
    • DevOps Tools
      • Operating Systems - Development platforms
        • NixOS
          • Install NixOS: PC, Mac, WSL
          • Nix Language Deep Dive
          • Nix Language Fundamentals
            • Nix Functions and Techniques
            • Building Packages with Nix
            • NixOS Configuration Patterns
            • Flakes: The Future of Nix
          • NixOS Generators: Azure & QEMU
        • WSL2
          • Distributions
          • Terminal Setup
      • Editor Environments
      • CLI Tools
        • Azure CLI
        • PowerShell
        • Linux Commands
          • SSH - Secure Shell)
            • SSH Config
            • SSH Port Forwarding
        • Linux Fundametals
        • Cloud init
          • Cloud init examples
        • YAML Tools
          • How to create a k8s yaml file - How to create YAML config
          • YQ the tool
  • 📚Programming Languages
    • Python
    • Go
    • JavaScript/TypeScript
    • Java
    • Rust
  • Platform Engineering
    • Implementation Guide
  • FinOps
    • Implementation Guide
  • AIOps
    • LLMOps Guide
  • Should Learn
    • Should Learn
    • Linux
      • Commands
      • OS
      • Services
    • Terraform
    • Getting Started - Installation and initial setup [BEGINNER]
    • Cloud Integrations
    • Testing and Validation - Ensuring infrastructure quality
      • Unit Testing
      • Integration Testing
      • End-to-End Testing
      • Terratest Guide
    • Best Practices - Production-ready implementation strategies
      • State Management
      • Security
      • Code Organization
      • Performance
    • Tools & Utilities
    • CI/CD Integration
    • Bicep
    • Kubernetes
      • kubectl
    • Ansible
    • Puppet
    • Java
    • Rust
    • Azure CLI
  • 📖Documentation Best Practices
    • Documentation Strategy
      • Project Documentation
      • Release Notes
      • Static Sites
      • Documentation Templates
      • Real-World Examples
  • 📋Reference Materials
    • Glossary
    • Tool Comparison
    • Tool Decision Guides
    • Recommended Reading
    • Troubleshooting Guide
    • Development Setup
Powered by GitBook
On this page
  • Step Schema
  • Step Types
  • Task
  • Script
  • PowerShell
  • Bash
  • Checkout
  • Download
  • Publish
  • Template
  • Step Properties
  • displayName
  • name
  • condition
  • continueOnError
  • env
  • timeoutInMinutes
  • workingDirectory
  • Examples
  • Basic Pipeline with Steps
  • Multiple Step Types
  • Conditional Step Execution
  • Using Output Variables
  • Step Templates
  • Advanced Container Example
  • Best Practices for Steps
Edit on GitHub
  1. CI/CD & GitOps
  2. CI/CD Overview
  3. CI/CD Platforms - Tool selection and implementation
  4. Azure DevOps
  5. Pipelines

Steps

Steps are the most fundamental building blocks of an Azure DevOps pipeline. Each step represents a single action to be performed during the execution of a job. When you define a pipeline with steps and without explicitly defining jobs, Azure DevOps will create an implicit job to contain those steps.

Step Schema

steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # Required. A list of steps to run in this job.
strategy: strategy # Execution strategy for this job.
continueOnError: string # Continue running even on failure?
pool: string | pool # Pool where jobs in this pipeline will run unless otherwise specified.
container: string | container # Container resource name.
services: # Container resources to run as a service container.
  string: string # Name/value pairs
workspace: # Workspace options on the agent.
  clean: string # Which parts of the workspace should be scorched before fetching.
name: string # Pipeline run number.
appendCommitMessageToRunName: boolean # Append the commit message to the build number. The default is true.
trigger: none | trigger | [ string ] # Continuous integration triggers.
parameters: [ parameter ] # Pipeline template parameters.
pr: none | pr | [ string ] # Pull request triggers.
schedules: [ cron ] # Scheduled triggers.
resources: # Containers and repositories used in the build.
  builds: [ build ] # List of build resources referenced by the pipeline.
  containers: [ container ] # List of container images.
  pipelines: [ pipeline ] # List of pipeline resources.
  repositories: [ repository ] # List of repository resources.
  webhooks: [ webhook ] # List of webhooks.
  packages: [ package ] # List of package resources.
variables: variables | [ variable ] # Variables for this pipeline.
lockBehavior: string # Behavior lock requests from this stage should exhibit in relation to other exclusive lock requests.

Step Types

Azure DevOps Pipelines supports several types of steps:

Task

A task is a pre-packaged script that performs a specific action. Azure DevOps provides many built-in tasks, and you can also use tasks from the marketplace.

- task: TaskName@version
  displayName: 'Human-readable step name'
  inputs:
    param1: value1
    param2: value2

Script

A script step runs a command-line script using cmd.exe on Windows and sh on other platforms.

- script: echo Hello, world!
  displayName: 'Say hello'

PowerShell

A PowerShell step runs a script using PowerShell on Windows, macOS, and Linux.

- powershell: |
    Write-Host "Hello from PowerShell"
    $PSVersionTable
  displayName: 'Run PowerShell'

Bash

A bash step runs a script using Bash on Windows, macOS, and Linux.

- bash: |
    echo "Hello from Bash"
    echo "Current directory: $(pwd)"
  displayName: 'Run Bash commands'

Checkout

The checkout step is used to check out source code from a repository.

- checkout: self  # self represents the repo where the pipeline is defined
  clean: true     # whether to fetch clean each time
  fetchDepth: 1   # the depth of commits to ask Git to fetch

Download

The download step downloads artifacts from the current or another pipeline run.

- download: current  # refers to artifacts published by current pipeline
  artifact: WebApp   # name of the artifact to download
  path: $(Build.ArtifactStagingDirectory)/WebApp  # download path

Publish

The publish step publishes (uploads) a file or folder as a pipeline artifact.

- publish: $(Build.ArtifactStagingDirectory)/WebApp
  artifact: WebApp
  displayName: 'Publish WebApp artifact'

Template

The template step includes steps from a template file.

- template: steps/build.yml  # Template reference
  parameters:
    buildConfiguration: 'Release'

Step Properties

Common properties that can be applied to steps include:

displayName

A friendly name displayed in the Azure DevOps UI.

- script: echo Hello
  displayName: 'Say Hello'

name

A reference name used in expressions.

- script: echo "Setting variable"
  name: setVariable

condition

A condition that determines whether the step should run.

- script: echo "This only runs if the previous step succeeded"
  condition: succeeded()

continueOnError

Whether to continue running more steps even if this step fails.

- script: exit 1
  continueOnError: true
  displayName: 'This step will fail but pipeline continues'

env

Environment variables to set for the step.

- script: echo "Using environment variable: $GREETING"
  env:
    GREETING: Hello, world!

timeoutInMinutes

The maximum time a step should run before it is canceled.

- script: sleep 300  # Run for 5 minutes
  timeoutInMinutes: 6
  displayName: 'Step with timeout'

workingDirectory

The working directory for the step.

- script: ls -la
  workingDirectory: $(Build.SourcesDirectory)/src
  displayName: 'List files in src directory'

Examples

Basic Pipeline with Steps

trigger:
- main

pool: 
  vmImage: ubuntu-latest

steps:
- script: echo "Hello world!"
  displayName: 'Print greeting'

Multiple Step Types

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

steps:
- checkout: self

- bash: |
    echo "Current directory: $(pwd)"
    echo "Repository files:"
    ls -la
  displayName: 'List files'

- task: UseDotNet@2
  displayName: 'Install .NET Core SDK'
  inputs:
    packageType: 'sdk'
    version: '6.0.x'

- script: |
    dotnet restore
    dotnet build --configuration Release
  displayName: 'Build the application'
  workingDirectory: $(Build.SourcesDirectory)/src

- task: DotNetCoreCLI@2
  displayName: 'Run unit tests'
  inputs:
    command: 'test'
    projects: '**/*Tests/*.csproj'
    arguments: '--configuration Release'

Conditional Step Execution

steps:
- script: echo "This always runs"
  displayName: 'Always run'

- script: echo "This runs only on main branch"
  displayName: 'Main branch only'
  condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')

- script: echo "This runs only on feature branches"
  displayName: 'Feature branch only'
  condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/')

- script: echo "This runs only if all previous steps succeeded"
  displayName: 'Run if all succeeded'
  condition: succeeded()

- script: echo "This runs even if previous steps failed"
  displayName: 'Run even on failure'
  condition: always()

Using Output Variables

steps:
- bash: |
    echo "##vso[task.setvariable variable=myOutputVar;isOutput=true]some value"
  name: setVarStep
  displayName: 'Set output variable'

- bash: |
    echo "The output variable is: $(setVarStep.myOutputVar)"
  displayName: 'Use output variable'
  condition: succeeded()

Step Templates

# azure-pipelines.yml
steps:
- template: templates/build-steps.yml
  parameters:
    buildConfiguration: 'Release'

# templates/build-steps.yml
parameters:
  buildConfiguration: 'Debug'

steps:
- script: dotnet build --configuration ${{ parameters.buildConfiguration }}
  displayName: 'Build with ${{ parameters.buildConfiguration }} configuration'

Advanced Container Example

pool:
  vmImage: 'ubuntu-latest'

container:
  image: mcr.microsoft.com/dotnet/sdk:6.0
  options: '--name ci-container -v /var/run/docker.sock:/var/run/docker.sock'

steps:
- script: |
    dotnet --version
    dotnet build
    dotnet test
  displayName: 'Build and test'

Best Practices for Steps

  1. Use descriptive displayNames: Give each step a clear, descriptive name to make pipeline logs easier to read.

  2. Group related commands: Use multi-line scripts for related commands rather than multiple separate script steps.

  3. Set timeouts: For steps that might hang, set timeoutInMinutes to prevent the pipeline from waiting indefinitely.

  4. Handle errors appropriately: Use continueOnError for non-critical steps where failures shouldn't stop the pipeline.

  5. Use conditions effectively: Apply conditions to skip unnecessary steps based on branch name, previous results, etc.

  6. Use step templates for reusability: Extract common sequences of steps into templates to avoid repetition.

  7. Leverage built-in expressions: Use Azure Pipelines expressions like succeeded(), failed(), always() for conditional execution.

  8. Manage working directories: Set the appropriate workingDirectory for each step rather than using cd commands.

  9. Be mindful of step order: Arrange steps in a logical order of dependency to ensure proper execution flow.

  10. Publish artifacts: Always publish important build artifacts to make them available to later stages and for troubleshooting.

PreviousJobsNextTemplates - Reusable pipeline components

Last updated 8 days ago

🔄