问题描述
使用Azure管道作为代码,并尝试使用YAML管道通过Azure中的ARM模板创建资源.
Working on Azure Pipeline as code and trying to create a resource via ARM template in Azure using YAML pipeline.
在Azure DevOps中,我已将代码(部署json,参数json和yml文件等)推送到功能分支下的Azure Repos Git中.
In Azure DevOps, I have pushed the code (deployment json, parameter json and yml file etc) into Azure Repos Git under a feature branch.
在运行管道时,由于"csmFile"值,我遇到错误错误:找不到与模板文件模式匹配的文件".
While running the pipeline, I am facing the error "Error: Could not find any file matching the template file pattern" due to "csmFile" value.
我的yml文件包含如下所示的ARM模板部署信息.
my yml file contains ARM template deployment info as below.
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'
我错过了什么吗?请指导我.谢谢.
Am I missing something? Please guide me. Thanks.
推荐答案
首先,仅供确认.
基于您在任务中定义的$(System.DefaultWorkingDirectory)/AzureAuto/pipelineascode.json
,您需要确保pipelineascode.json
在存储库中的位置应如下所示:
Based on this $(System.DefaultWorkingDirectory)/AzureAuto/pipelineascode.json
you defined in the task, you need make sure the location of pipelineascode.json
in repos should like this:
Repository
| AzureAuto
| | pipelineascode.json
| | param-pipelineascode.json
这是我的存储库样本:
如果您的ARM模板存储库的结构确实符合上述要求,那么现在我想它应该与您的分支相关.
If the structure of your ARM template repository indeed respect above mentioned, now I guess it should relevant with your branch.
您的 master 分支仍然包含AzureAuto
文件夹和pipelineascode.json
/param-pipelineascode.json
文件吗?
Does your master branch still contain AzureAuto
folder and the pipelineascode.json
/param-pipelineascode.json
files?
您可以转至遇到构建错误消息的build result
页面,并确认分支名称是否是您存储的ARM模板文件的名称:
You can go the build result
page you encountered the build error message, and confirm whether the branch name is the one you stored the ARM template files:
至于我为什么会这样,这是因为系统默认情况下会基于master分支构建,而用户会先从 new YAML管道和第一个开始运行它.
As for why I guess so, it is because the system will build based on master branch by default while user start with the new YAML pipeline and first run it.
这时,您需要将azure-pipelines.yml
文件从master
分支复制到存储ARM模板文件的功能分支.
At this time, you need copy the azure-pipelines.yml
file from master
branch to that feature branch which stored ARM templates files.
然后转到Pipelines
=>打开相应的YAML版本=> 编辑 =>专注于左上角并更改分支:
Then go Pipelines
=> Open corresponding YAML build => Edit => Focus on upper left corner and change the branch:
现在,此YAML管道应建立在您存储ARM模板的正确分支上,并成功找到JSON文件.
Now, this YAML pipeline should build on the correct branch you stored the ARM templates and succeed to find the JSON file.
这篇关于Azure管道错误:找不到与模板文件模式匹配的任何文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!