azure - 当特定文件更改时触发管道

标签 azure azure-devops azure-pipelines

我正在创建一个新的 CI 管道,每当 .bicep 文件发生更改时都会触发该管道,然后压缩所有文件。

# Pipeline is triggered anytime there is a change to .bicep files
trigger:
  branches:
    include:
      - "feature/*"
pool:
  vmImage: ubuntu-latest

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

此管道可以工作,并会在功能分支中发生更改时触发。

要定位我正在尝试的任何 .bicep 文件:

trigger:
  branches:
    include:
      - "feature/*"
  paths:
    include:
      - '**/*.bicep'

我还尝试指定保存文件的整个路径:

trigger:
  branches:
    include:
      - "feature/*"
  paths:
    include:
      - "src/Deployment/IaC/Bicep/*"

当我对功能分支中的 .bicep 文件进行更改时,管道永远不会触发,因此我知道我的语法是错误的。

最佳答案

Azure 管道不再支持通配符。 相反,只需设置 Bicep 文件夹的相对路径,如下所示:

paths:
include:
  - src/Deployment/IaC/Bicep

参见:https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?tabs=yaml&view=azure-devops#paths enter image description here

关于azure - 当特定文件更改时触发管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68808475/

相关文章:

azure - Web api 中的 Crystal 报表在 azure 服务器中无法工作

azure - 如何查看服务主体有权访问的 Azure 订阅列表?

docker - 获取Build.Repository.LocalPath的数据并在我的DockerFile中使用它

azure - 将变量传递到 YAML 文件中

Azure存储-下载文件并放入存储中

azure - 闲置 Azure 容器实例以削减成本

azure - 当唯一的共享存储库需要不同类型的任务时,如何共享 Azure DevOps 作业结果?

maven - 我可以通过私有(private)托管代理的 Azure DevOps Artifact 访问 Maven 中心吗?

tfs - 从 TFS 2017 构建定义中的 'Copy Files' 步骤中排除整个文件夹/内容

c# - 在 Azure Eventhub 中发布数据时出现未经授权的错误