gpt4 book ai didi

Azure DevOps : Monorepo trigger

转载 作者:行者123 更新时间:2023-12-02 07:56:05 25 4
gpt4 key购买 nike

我有一个具有以下结构的单一存储库:

.
├── 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

entry-point1.py和entry-point2.py具有用common.py编写的公共(public)函数。

  • 如果我对 common.py 进行更改:azure-pipelines 会被触发
  • 如果我对entry-point1.py进行更改:azure-pipelines-sample-job1被触发
  • 如果我对entry-point2.py进行更改:azure-pipelines-sample-job2被触发

我还想要的是:

  • 如果我对 common.py 进行更改(仅当该文件被修改时),我希望触发其他 2 个管道azure-pipelines-sample-job1.yml、azure-pipelines-sample-job2.yml 中除了触发 azure-pipelines.yml 的现有逻辑之外

这是因为entry-point1.py和entry-point2.py调用common.py,因此每次common.py更改时都需要重新构建代码。

如何添加此触发器?

以下是我目前拥有的触发器:

#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'"

最佳答案

如果您想在文件“common.py”时触发azure-pipelines-sample-job1.ymlazure-pipelines-sample-job2.yml ”已修改,只需将其路径添加到触发路径中即可:

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'"

参见:Paths了解详情。

关于Azure DevOps : Monorepo trigger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65649039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com