Azure devops 将文件引用作为参数传递给Azure YAML部署中来自另一个repo的插入步骤

Azure devops 将文件引用作为参数传递给Azure YAML部署中来自另一个repo的插入步骤,azure-devops,azure-pipelines,azure-pipelines-yaml,Azure Devops,Azure Pipelines,Azure Pipelines Yaml,我有一个基于yaml的作业库,我想在许多yaml脚本中重用这些作业。但是,将使用作业的脚本位于其他存储库中 可重用作业将文件路径作为输入参数。由于某些原因,当导入的作业通过管道执行时,无法找到该文件 如何从主作业中引用参数中的文件,以便在执行导入的作业时可以找到该文件 请检查一下 我建议您采取两个步骤: 在调用模板之前添加-签出:AzureTemplates步骤 并将路径从/Azure/Functions/template.json更改为(Agent.BuildDirectory)/Azure

我有一个基于yaml的作业库,我想在许多yaml脚本中重用这些作业。但是,将使用作业的脚本位于其他存储库中

可重用作业将文件路径作为输入参数。由于某些原因,当导入的作业通过管道执行时,无法找到该文件

如何从主作业中引用参数中的文件,以便在执行导入的作业时可以找到该文件

请检查一下

我建议您采取两个步骤:

  • 在调用模板之前添加
    -签出:AzureTemplates
    步骤
  • 并将路径从
    /Azure/Functions/template.json
    更改为
    (Agent.BuildDirectory)/AzureTemplates/Azure/Functions/template.json

是的-谢谢-我错了构建目录路径…酷。我很高兴你解决了你的问题。你能考虑一下我的回答吗?
# 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"