基本原則

  • Variables in trigger block is not supported.
  • Maybe all YAML file of Pipelines are same in all branches.

template

detect CHANGED Dir to build & deploy

  • coding in PowerShell to detect What files are changed,
  • get DIR and combine ARRAY
  • build & deploy via FACTORY PATTERN

References:

開始 try 的:

variables:
  f1Flag: false
  f2Flag: false

trigger:
  branches:
    include:
      - master
  # paths:
  #   include:
  #     - "test_pipelines/*"

steps:
  - powershell: |
      ## get the changed files
      $files=$(git diff-tree --no-commit-id --name-only -r $(Build.SourceVersion))
      $temp=$files -split ' '
      $count=$temp.Length
      echo "Total changed $count files"      
     
      For ($i=0; $i -lt $temp.Length; $i++)
      {
        $name=$temp[$i]
        echo "this is $name file"
        if ($name -like 'test_pipelines/*')  #if test_pipelines is a subfolder under a folder use "- like '*/f1/*'"
        {
          ##set the flag variable f1Flag to true
          Write-Host "##vso[task.setvariable variable=f1Flag]true"
        }
      }
  - script: echo $(f1Flag)
  - script: echo $(f2Flag)

just clone DIR