Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates Azure DevOps模板不工作(意外值)_Templates_Azure Devops_Yaml - Fatal编程技术网

Templates Azure DevOps模板不工作(意外值)

Templates Azure DevOps模板不工作(意外值),templates,azure-devops,yaml,Templates,Azure Devops,Yaml,我想包括一个模板,但它不会工作。我知道这是一个重复的问题,但其他答案并不能解决我的问题 模板文件(base.yml) Azure Pipelines.yml trigger: - master pool: 'Etiscan Windows' variables: solution: '**/*.sln' buildPlatform: 'x86' buildConfiguration: 'Release' steps: - task: NuGetToolInstaller@1 -

我想包括一个模板,但它不会工作。我知道这是一个重复的问题,但其他答案并不能解决我的问题

模板文件(base.yml)

Azure Pipelines.yml

trigger:
- master

pool: 'Etiscan Windows'

variables:
  solution: '**/*.sln'
  buildPlatform: 'x86'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    vstsFeed: '76b8ae4e-2263-4849-bfb3-e1f621bf5bd7'
...to be continued....
resources:
  repositories:
  - repository: templates
    type: git
    name: YML-Templates/NugetCfBuilderTemplate
stages:
 - stage: Job1
 - template: base.yml@templates
错误

/base.yml@templates (Line: 6, Col: 1): Unexpected value 'trigger' /base.yml@templates (Line: 9, Col: 1): Unexpected value 'pool' /base.yml@templates (Line: 11, Col: 1): Unexpected value 'variables' /base.yml@templates (Line: 16, Col: 1): Unexpected value 'steps'

触发器只能在管道级别定义,不能在阶段级别设置。舞台上只能有这些孩子(请参见):

阶段:
-stage:string#stage的名称(A-Z、A-Z、0-9和下划线)
displayName:string#要在UI中显示的友好名称
dependsOn:string |[string]
条件:字符串
变量:#多个语法,见具体章节
作业:[作业|模板参考]

您还需要插入包含步骤的作业,并将池节下移到作业级别。

在资源中,我们还可以添加触发器,请参阅。帮助您修改yaml,希望这将有助于:

resources:
  repositories:
  - repository: templates
    type: git
    name: YML-Templates/NugetCfBuilderTemplate
    trigger: 
      branches:
        include:
          - master
stages:
 - stage: Job1
 - template: base.yml@templates    
注意:请删除base.yml文件中的触发器

更新: 我帮助您修改了基本yaml,这里我使用Powershell任务进行测试:

stages:
  - stage: job1
    pool: 'default' 
    variables:
      solution: '**/*.sln'
      buildPlatform: 'x86'
      buildConfiguration: 'Release'
    jobs:
      - job: A1
        steps:
        - task: PowerShell@2
          inputs:
            targetType: 'inline'
            script: |
              # Write your PowerShell commands here.
              
              Write-Host "Hello World"
#       - task: NuGetToolInstaller@1
        # - task: NuGetCommand@2
        #   inputs:
        #     command: 'restore'
        #     restoreSolution: '**/*.sln'
        #     feedsToUse: 'select'
        #     vstsFeed: '76b8ae4e-2263-4849-bfb3-e1f621bf5bd7'

注意:请从主yaml文件中删除“-stage:Job1”。

好的,“trigger”错误已经消失。但是“意外值”池、变量和步骤的错误仍然存在。Hi@etalon11,我帮助您修改了演示yaml,并使用我的“默认”池进行测试。您可以使用更新yaml重试。请不要忘记从主yaml文件中删除“-stage:Job1”。我帮你把base.yaml命名为舞台工作1这个问题怎么样?下面的答案是否解决了您的问题,如果是,您可以接受它作为一个答案,这样它可以帮助其他社区成员谁得到相同的问题,我们可以存档此线程,谢谢。如果没有,请告诉我们您是否需要进一步的帮助