Microsoft Azure Pipelines

Azure pipelines support the CI/CD (Continuous Integration, Continuous Deployment), the fully automated Continuous Delivery process.

Agents, either hosted by Microsoft, or self-hosted on the client’s infrastructure, execute the yaml scripts.

Steps

The smallest unit of work in the Azure Pipeline. Each step is one action in a job. A Step can be a Script or a Task.

Script

A Script is a command written in a scripting language to be executed as a step of a job.

Running a Bash Script

steps:
- script: echo "Hello, World!"
  displayName: 'Script to say Hello'
Task

A Task is a packaged script that can be used as a step within a job:

  • Built-in tasks from Azure Pipeline
  • Custom scripts written in PowerShell, Bash, Python or other languages
  • Third-party tasks from the Azure DevOps Marketplace

Running a Task, to execute an Azure CLI command with attributes

steps:
- task: AzureCLI@2
  displayName: 'Run Azure CLI Command'
  inputs:
    azureSubscription: 'MyAzureSubscription' # Service connection to Azure
    scriptType: 'bash'                     # Specify the script type (bash or ps)
    scriptLocation: 'inlineScript'          # Define the script location
    inlineScript: |                         # Start the inline script
      echo "Listing all resources in the resource group..."
      az resource list --resource-group MyResourceGroup

Jobs

The job is a single phase of the pipeline executing multiple steps. Jobs can run in parallel or in sequence if those depend on each other. It has its own context and workspace, so variables and files created in one job are kept separate from each other. This allows the easier troubleshooting of the process. Typical steps are:

  • Building code
  • Running tests

Stages

Stages hold related jobs together. It can represent

  • Environments, like
    • Development,
    • QA,
    • Production,
  • or Related jobs, like
    • Build,
    • Test,
    • Deploy.

Triggers

Triggers tells the pipeline to run. It can be based on

  • Events, like
    • A commit to a repository or
    • A pull request
  • or Schedules
    • To run at specific times, like end of the day.

Approval

Gatekeeper before the stage can proceed. The pipeline execution pauses until the approval arrives. It can be

  • Manual (like human approval is required before deployment to Production)
  • Automatic (like only during business hours, or when automated tests are passed)

Leave a comment

Your email address will not be published. Required fields are marked *