Azure Pipelines Tutorial

What is Azure Pipelines?

Azure Pipelines is a cloud service that you can use to automatically build and test your code projects and make them available to users. It works with any language, platform, or cloud, and integrates with GitHub, Azure Repos, Bitbucket, and many others.

Key Features

Getting Started – A Simple YAML Pipeline

Create a file named azure-pipelines.yml at the root of your repository:

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: UseNode@2
  inputs:
    version: '18.x'

- script: |
    npm install
    npm run build
  displayName: 'Install and Build'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: 'dist'
    ArtifactName: 'drop'

Run the Pipeline

  1. Push the YAML file to your repo.
  2. Navigate to Azure DevOps → Pipelines → New Pipeline.
  3. Select your repository and let Azure detect the azure-pipelines.yml file.
  4. Run the pipeline and watch the logs in real time.

Advanced: Multi‑Stage Pipelines

Define separate stages for build, test, and release:

trigger:
- main

stages:
- stage: Build
  jobs:
  - job: BuildJob
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - script: npm install
      displayName: 'Install dependencies'
    - script: npm run build
      displayName: 'Build app'
    - publish: $(Build.ArtifactStagingDirectory)
      artifact: drop

- stage: Test
  dependsOn: Build
  jobs:
  - job: TestJob
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - download: current
      artifact: drop
    - script: npm test
      displayName: 'Run tests'

- stage: Deploy
  dependsOn: Test
  condition: succeeded()
  jobs:
  - deployment: DeployJob
    environment: 'Production'
    pool:
      vmImage: 'ubuntu-latest'
    strategy:
      runOnce:
        deploy:
          steps:
          - download: current
            artifact: drop
          - script: echo 'Deploying to production...'
            displayName: 'Deploy'

Resources