将文件引用作为参数传递到 Azure YAML 部署中另一个存储库的插入步骤
Pass a file reference as a parameter to a inserted step from another repo in a Azure YAML deployment
我有一个基于 yaml 的作业的存储库,我想在多个 yaml 脚本中重复使用它。然而,将使用作业的脚本位于其他存储库中。
可重用作业将文件路径作为输入参数。并且由于某种原因,当管道执行导入的作业时找不到文件。
如何在主作业的参数中引用文件,以便在执行导入的作业时可以找到它?
# MyMainScriptTemplate.yml that will be executed by the pipeline
trigger:
- master
resources:
repositories:
- repository: AzureTemplates
type: git
name: AzureTemplates
jobs:
- template: /FunctionApp/DeployFunctionApp.yml@AzureTemplates
parameters:
file: /Azure/Functions/template.json #This can be found when executing ...
# ReusableJobTemplate.yml defines a job that should be referenced from the main script
parameters:
- name: file
type: string
jobs:
- job: DeployFunctionApp
steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: "Resource Group"
azureResourceManagerConnection: "Dev"
subscriptionId: "XYZ"
action: "Create Or Update Resource Group"
resourceGroupName: "XYZ"
location: "West Europe"
templateLocation: "Linked artifact"
csmFile: ${{ parameters.file }}
deploymentMode: "Incremental"
displayName: "Run a one-line script"
请检查mulirepo behaves。
我会推荐你两个步骤:
- 在调用模板之前添加
- checkout: AzureTemplates
步骤
- 并将路径从
/Azure/Functions/template.json
更改为 (Agent.BuildDirectory)/AzureTemplates/Azure/Functions/template.json
我有一个基于 yaml 的作业的存储库,我想在多个 yaml 脚本中重复使用它。然而,将使用作业的脚本位于其他存储库中。
可重用作业将文件路径作为输入参数。并且由于某种原因,当管道执行导入的作业时找不到文件。
如何在主作业的参数中引用文件,以便在执行导入的作业时可以找到它?
# MyMainScriptTemplate.yml that will be executed by the pipeline
trigger:
- master
resources:
repositories:
- repository: AzureTemplates
type: git
name: AzureTemplates
jobs:
- template: /FunctionApp/DeployFunctionApp.yml@AzureTemplates
parameters:
file: /Azure/Functions/template.json #This can be found when executing ...
# ReusableJobTemplate.yml defines a job that should be referenced from the main script
parameters:
- name: file
type: string
jobs:
- job: DeployFunctionApp
steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: "Resource Group"
azureResourceManagerConnection: "Dev"
subscriptionId: "XYZ"
action: "Create Or Update Resource Group"
resourceGroupName: "XYZ"
location: "West Europe"
templateLocation: "Linked artifact"
csmFile: ${{ parameters.file }}
deploymentMode: "Incremental"
displayName: "Run a one-line script"
请检查mulirepo behaves。
我会推荐你两个步骤:
- 在调用模板之前添加
- checkout: AzureTemplates
步骤 - 并将路径从
/Azure/Functions/template.json
更改为(Agent.BuildDirectory)/AzureTemplates/Azure/Functions/template.json