简体   繁体   English

Azure devops:Monorepo 触发器

[英]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. entry-point1.py 和 entry-point2.py 有共同的函数写在 common.py 中。

  • If I make changes to common.py: azure-pipelines get triggered如果我对 common.py 进行更改:azure-pipelines 被触发
  • If I make changes to entry-point1.py: azure-pipelines-sample-job1 get triggered如果我对 entry-point1.py 进行更改:azure-pipelines-sample-job1 会被触发
  • If I make changes to entry-point2.py: azure-pipelines-sample-job2 get triggered如果我对 entry-point2.py 进行更改:azure-pipelines-sample-job2 会被触发

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如果我对 common.py 进行更改(仅在修改此文件的情况下),除了现有的之外,我还希望触发其他 2 个管道 azure-pipelines-sample-job1.yml、azure-pipelines-sample-job2.yml触发 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.这是因为 entry-point1.py 和 entry-point2.py 调用了 common.py,所以每次 common.py 更改时都需要重新构建代码。

How do I add this trigger?如何添加此触发器?

Below is the current triggers I have:以下是我目前拥有的触发器:

#azure-pipelines.yml #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 #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 #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:如果要在修改文件“ common.py ”时触发azure-pipelines-sample-job1.ymlazure-pipelines-sample-job2.yml ,只需将其路径添加到触发路径:

azure-pipelines-sample-job1.yml天蓝色管道样本-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天蓝色管道样本-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.有关详细信息,请参阅: 路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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