You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OneBuild Pipeline验证报错:找不到templates仓库(文件已存在)

问题解决:OneBuild Pipeline验证提示"No repository found by name templates"

问题重现

创建OneBuild Pipeline并关联OneBuild.Buddy.yml后,验证时触发错误:

Validation: /.pipelines/OneBranch.Buddy.yml: No repository found by name templates

YAML已通过独立语法验证,确认无语法错误。

核心原因

  1. 模板仓库未声明:YAML中通过@templates引用了外部模板仓库,但未在resources段中明确声明该仓库的来源,OneBuild无法定位到模板所在的仓库。
  2. YAML层级错误:原配置中stages被错误嵌套在globalSdl参数下,导致模板参数解析异常,间接引发验证失败。

解决方案

1. 添加模板仓库声明

在YAML最顶部添加resources段,明确指定templates仓库的信息:

resources:
  repositories:
    - repository: templates
      type: git
      name: Microsoft/OneBranchTemplates # 替换为你实际使用的模板仓库名称
      ref: refs/tags/v2 # 可选,指定模板仓库的版本分支/标签

2. 修正YAML层级结构

将原嵌套在globalSdl下的stages移到parameters的直接子级,确保模板参数结构正确。

修正后的完整YAML

# Pipeline that builds whl file

resources:
  repositories:
    - repository: templates
      type: git
      name: Microsoft/OneBranchTemplates
      ref: refs/tags/v2

trigger:
  - feature/*

variables:
  CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)]
  ENABLE_PRS_DELAYSIGN: 1
  ROOT: $(Build.SourcesDirectory)
  REPOROOT: $(Build.SourcesDirectory)
  OUTPUTROOT: $(REPOROOT)\out
  NUGET_XMLDOC_MODE: none
  WindowsContainerImage: 'cdpxwin1809.azurecr.io/global/vse2019:latest'
  BLACK_OPTS: '-vv --diff -t py38 --check'

pool:
  vmImage: ubuntu-latest

extends:
  template: v2/OneBranch.Official.CrossPlat.yml@templates
  parameters:
    cloudvault:
      enabled: false
    globalSdl:
      tsa:
        enabled: false
      binskim:
        break: true
      policheck:
        break: true
    stages:
      - stage: test
        jobs:
        - job: Run Tests
          steps:
            - script: |
                python -m pip install --upgrade pip    
                python -m pip install pytest
              displayName: "Install dependencies"

            - script: |
                make test
              displayName: "Run unit tests"

            - task: Bash@3
              inputs:
                filePath: $(Build.SourcesDirectory)/src/framework/scripts/run-unit-tests-report
      - stage: build
        jobs:
        - job: Build Wheel
          steps:
          - task: Bash@3
            inputs:
              targetType: 'inline'
              workingDirectory: $(Build.SourcesDirectory)/src/framework
              script: |
                make dist
            displayName: Make the whl

      - stage: publish
        jobs:
        - job: Copy Wheel Artifact
          steps:
          - task: CopyFiles@2
            inputs:
              SourceFolder: $(Build.SourcesDirectory)/src/framework/dist
              Contents: '**.whl'
              targetFolder: $(Build.ArtifactStagingDirectory)
            displayName: Copy to artifact staging

        - job: Publish Wheel
          steps:
          - task: PublishBuildArtifacts@1
            inputs:
              PathtoPublish: '$(Build.ArtifactStagingDirectory)'
              ArtifactName: 'dist'
            displayName: Publish to artifact feed

额外检查点

  • 确保当前Pipeline所在项目拥有访问templates仓库的权限,必要时在仓库设置中添加项目权限或服务连接。

内容的提问来源于stack exchange,提问作者WestCoastProjects

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 09:54:58