简体   繁体   中英

Azure devops: Monorepo trigger

I have a mono-repo with the below structure:

.
├── README.md
├── azure-pipelines.yml
├── common.py
├── sample-job1
|── azure-pipelines-sample-job1.yml
│   └── entry-point1.py
└── sample-job2
    |── azure-pipelines-sample-job2.yml
    └── entry-point2.py

The entry-point1.py and entry-point2.py have common functions written in common.py.

  • If I make changes to common.py: azure-pipelines get triggered
  • If I make changes to entry-point1.py: azure-pipelines-sample-job1 get triggered
  • If I make changes to entry-point2.py: azure-pipelines-sample-job2 get triggered

What I would like to have in addtion is:

  • if I make changes to common.py (only if this file is modified), I want the other 2 pipelines to be triggered azure-pipelines-sample-job1.yml, azure-pipelines-sample-job2.yml in addition to the existing logic to trigger azure-pipelines.yml

This is because entry-point1.py and entry-point2.py calls common.py so a rebuild of the code is necessary every time common.py is changed.

How do I add this trigger?

Below is the current triggers I have:

#azure-pipelines.yml

# Build numbering format
name: $(BuildID)

trigger:
  branches:
    include:
      - test
      - feat/*
  paths:
    exclude:
      - 'sample-job1/*'
      - 'sample-job2/*'

pool:
  vmImage: 'ubuntu-latest'

steps:
  - script: |
      echo "Hello from '/' root folder."
  
  

#azure-pipelines-sample-job1.yml

# Build numbering format
name: $(BuildID)

trigger:
  branches:
    include:
      - test
      - feat/*
  paths:
    include:
      - 'sample-job1/*'

pool:
  vmImage: 'ubuntu-latest'

steps:
  - script: |
      echo "Hello from 'sample1'"
  
  

#azure-pipelines-sample-job2.yml

# Build numbering format
name: $(BuildID)

trigger:
  branches:
    include:
      - test
      - feat/*
  paths:
    include:
      - 'sample-job2/*'

pool:
  vmImage: 'ubuntu-latest'

steps:
  - script: |
      echo "Hello from 'sample2'"

If you want to trigger azure-pipelines-sample-job1.yml and azure-pipelines-sample-job2.yml when file “ common.py ” is modified, just add its path to the trigger paths:

azure-pipelines-sample-job1.yml

# Build numbering format
name: $(BuildID)
 
trigger:
  branches:
    include:
      - test
      - feat/*
  paths:
    include:
      - 'sample-job1/*'
      - 'common.py'
 
pool:
  vmImage: 'windows-latest'
 
steps:
  - script: |
      echo "Hello from 'sample1'"

azure-pipelines-sample-job2.yml

# Build numbering format
name: $(BuildID)
 
trigger:
  branches:
    include:
      - test
      - feat/*
  paths:
    include:
      - 'sample-job2/*'
      - 'common.py'
 
pool:
  vmImage: 'windows-latest'
 
steps:
  - script: |
      echo "Hello from 'sample2'"

See: Paths for details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM