Skip to main content

Azure Pipelines

Azure Pipelines can run dagger check in any pipeline, so the same checks you run locally run on every push — without rewriting your pipeline.

tip

For checks with no pipeline YAML at all, enable Cloud Checks with dagger ws autocheck on. The Azure Pipeline below is the hybrid-mode alternative for when you want to drive Dagger from your existing Azure Pipelines setup.

How it works​

When running a CI pipeline with Dagger using Azure Pipelines, the general workflow looks like this:

  1. Azure Pipelines receives a trigger based on a repository event.
  2. Azure Pipelines begins processing the steps in the azure-pipelines.yml file.
  3. Azure Pipelines downloads the Dagger CLI.
  4. Azure Pipelines runs dagger check against the modules installed in your workspace.
  5. The Dagger CLI attempts to find an existing Dagger Engine or spins up a new one inside the Azure Pipelines runner.
  6. The Dagger CLI sends telemetry to Dagger Cloud if the DAGGER_CLOUD_TOKEN environment variable is set.
  7. The pipeline completes with success or failure, based on the check results. Logs appear in Azure Pipelines as usual.

Prerequisites​

  • An Azure DevOps organization and project
  • An Azure Pipelines agent to run jobs connected to the project
  • A repository with a Dagger workspace (.dagger/config.toml) — see Workspace Setup.

Example​

The following example runs all of your workspace's checks with dagger check:

azure-pipelines.yml
trigger:
- main

pool:
name: 'Azure Pipelines'
vmImage: ubuntu-latest

steps:
# full clone checkout required to prevent azure pipeline traces from being orphaned in the Dagger Cloud UI
- checkout: self
fetchDepth: 0
displayName: 'Checkout Source Code, fetch full history'
# branch checkout required to prevent azure pipeline traces from being orphaned in the Dagger Cloud UI
- script: git checkout $(Build.SourceBranchName)
displayName: 'Checkout Source Branch'
- script: curl -fsSL https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
displayName: 'Install Dagger CLI'
- script: dagger check
displayName: 'Run Dagger checks'
env:
# assumes the Dagger Cloud token is
# in a secret named DAGGER_CLOUD_TOKEN
# set via the Azure Pipeline settings UI/CLI
# the secret is then explicitly mapped to the script env
DAGGER_CLOUD_TOKEN: $(DAGGER_CLOUD_TOKEN)

dagger check runs every check and exits non-zero if any fails. You can scope it to a subset — for example dagger check go:* to run a single module's checks.

Dagger Cloud Engines​

By default the Dagger CLI starts a Dagger Engine inside the Azure Pipelines runner. For a faster, more reliable experience, offload execution to a managed Dagger Engine provided by Dagger Cloud by adding --cloud to the command:

dagger check --cloud

Cloud Engines provide a large persistent cache shared across runs and far more compute than an Azure Pipelines runner, so checks are typically much faster — and you don't provision or maintain any infrastructure. This requires the DAGGER_CLOUD_TOKEN secret configured for the pipeline.

Resources​

If you have any questions about additional ways to use Azure Pipelines with Dagger, join our Discord and ask your questions in our help channel.

About Azure Pipelines​

Azure Pipelines is the CI/CD service of Azure DevOps. It enables developers to quickly and easily build, test and deploy their applications, and works with multiple languages and platforms. It supports both self-hosted and managed agents.