Azure DevOps: CI/CD IaC with YAML Pipeline

Sign in to your organisation (https://dev.azure.com/{yourorganization})

Azure DevOps looks like the following screenshot.

Azure DevOps Organizations Page

Azure DevOps Selected Organization Page

Azure DevOps Pipelines in Project Page

Find all the pipelines in https://github.com/kenanhancer/azure-devops-ci-cd-demo GitHub repository.

Demo 1

stages:
  - stage: Stage_A
    jobs:
    - job: MyJob
      steps:
      - checkout: none
      
      - script: echo My first job
  
  - stage: Stage_B
    jobs:
    - job: MyJob2
      steps:
      - checkout: none

      - script: echo My Second job

Find all runs in Azure DevOps

After clicking any stage or job, we will see the following screenshot.

Demo 2

stages:
  - stage: Stage_A
    jobs:
    - job: MyJob
      steps:
      - checkout: none
      
      - script: echo My first job
  
  - stage: Stage_B
    dependsOn: Stage_A
    jobs:
    - job: MyJob2
      steps:
      - checkout: none

      - script: echo My Second job

  - stage: Stage_C
    dependsOn: Stage_B
    jobs:
    - job: MyJob3
      steps:
      - checkout: none

      - script: echo My Third job

      - script: echo My Fourth job

      - script: echo My Fifth job

Find all runs in Azure DevOps

Demo 3

jobs:
  - job: MyJob
    steps:
    - checkout: none
    
    - script: echo My first job

Find all runs in Azure DevOps

Demo 4

steps:
- checkout: none

- script: echo My first job

Find all runs in Azure DevOps

Demo 5

stages:
  - stage: Build
    jobs:
    - job: BuildJob
      steps:
      - checkout: none

      - script: echo Building!

  - stage: Test
    jobs:
    - job: TestOnWindows
      steps:
      - checkout: none

      - script: echo Testing on Windows!

    - job: TestOnLinux
      steps:
      - checkout: none

      - script: echo Testing on Linux!

  - stage: Deploy
    jobs:
    - job: Deploy
      steps:
      - checkout: none
      
      - script: echo Deploying the code!

Find all runs in Azure DevOps

Demo 6

stages:
  - stage: BuildWin
    displayName: Build for Windows
    jobs:
      - job: Build
        steps:
        - checkout: none

        - script: echo Building in Windows!

  - stage: BuildLinux
    displayName: Build for Linux
    dependsOn: [] # by specifying an empty array, this stage doesn't depend on the stage before it
    jobs:
      - job: Build
        steps:
        - checkout: none

        - script: echo Building in Linux!

  - stage: TestOnWindows
    dependsOn: BuildWin
    jobs:
    - job: TestOnWindows
      steps:
      - checkout: none

      - script: echo Testing on Windows!

  - stage: TestOnLinux
    dependsOn: BuildLinux
    jobs:
    - job: TestOnLinux
      steps:
      - checkout: none

      - script: echo Testing on Linux!

  - stage: DeployWindows
    dependsOn: TestOnWindows
    jobs:
    - job: Deploy
      steps:
      - checkout: none

      - script: echo Deploying the code to Windows!

  - stage: DeployLinux
    dependsOn: TestOnLinux
    jobs:
    - job: Deploy
      steps:
      - checkout: none
      
      - script: echo Deploying the code to Linux!

Find all runs in Azure DevOps

Demo 7

trigger:
  - master
  
pool: 
  vmImage: ubuntu-latest

jobs:
- job: PreWork
  steps:
  - checkout: none

  - script: echo "Do pre-work"

- job: PostWork
  steps:
  - checkout: none

  - script: echo "Do post-work using a different hosted image"

Find all runs in Azure DevOps

Leave a Reply