Azure Pipeline 错误。找不到任何与模板文件模式匹配的文件。

问题描述 投票:0回答:1

以代码的形式在Azure Pipeline上工作,并尝试在Azure中通过ARM模板使用YAML pipeline创建资源。

在Azure DevOps中,我已经将代码(部署json、参数json和yml文件等)推送到Azure Repos Git的一个特性分支下。

在运行流水线时,我面临着错误 "Error: Could not find any file matching the template file pattern"(错误:找不到任何与模板文件模式匹配的文件),原因是 "csmFile "值。

我的 yml 文件包含 ARM 模板部署信息,如下所示。

    trigger:
 branches:
    include:
    - dev-pipecode

pool:
  vmImage: 'windows-latest'

steps:

- task: AzureResourceManagerTemplateDeployment@3
  inputs:
    deploymentScope: 'Resource Group'
    azureResourceManagerConnection: 'company-development-Contributor'
    subscriptionId: 'XXXXXXXX'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'name of the resource group'
    location: 'North Europe'
    templateLocation: 'Linked artifact'
    csmFile: '$(System.DefaultWorkingDirectory)/AzureAuto/pipelineascode.json'
    csmParametersFile: '$(System.DefaultWorkingDirectory)/AzureAuto/param-pipelineascode.json'
    deploymentMode: 'Incremental'

我是否遗漏了什么?请指导我。谢谢。

azure-devops azure-pipelines azure-pipelines-release-pipeline arm-template
1个回答
1
投票

首先,只是为了确认。

基于此 $(System.DefaultWorkingDirectory)/AzureAuto/pipelineascode.json 您在任务中定义的,您需要确定 pipelineascode.json 在repos中应该是这样的。

   Repository
    |    AzureAuto
    |    |   pipelineascode.json
    |    |   param-pipelineascode.json

这是我的版本库样本。

enter image description here


如果你的ARM模板库的结构确实符合上面提到的要求,那么现在我想它应该和你的分支相关。

你的 掌握 蕴含 AzureAuto 文件夹和 pipelineascode.jsonparam-pipelineascode.json 文件?

你可以去 build result 页面遇到的构建错误信息,并确认该分支名称是否是你存储ARM模板文件的分支。

enter image description here

至于为什么我猜测是这样的,是因为系统会... 默认基于主分支构建 当用户开始用 新的 YAML管道和 第一 运行它。

这个时候,你需要 拷贝azure-pipelines.yml 文件从 master 分支到那个存储ARM模板文件的功能分支。

然后去 Pipelines => 打开相应的YAML构建=&gt。编辑 => 关注左上角并更改分支。

enter image description here

现在,这个YAML管道应该建立在你存储ARM模板的正确分支上,并成功找到JSON文件。

© www.soinside.com 2019 - 2024. All rights reserved.