skip to Main Content

I have created a new OneBuild Pipeline and associated a OneBuild.Buddy.yml with it. But when trying to run validation here:

enter image description here

we get:

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

Build validation error

But the file exists – which is clear since the contents are displayed right there. So what does the error mean?

Note: this question differs from a similarly named one ADO YAML failing: No repository found by name templates because that one had a syntax error but mine passes an independent yml validator

Here is the pipeline yaml

# Pipeline that builds whl file

trigger:
  - feature/*

variables:
  CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
  ENABLE_PRS_DELAYSIGN: 1
  ROOT: $(Build.SourcesDirectory)
  REPOROOT: $(Build.SourcesDirectory)
  OUTPUTROOT: $(REPOROOT)out
  NUGET_XMLDOC_MODE: none
  WindowsContainerImage: 'cdpxwin1809.azurecr.io/global/vse2019:latest' # Docker image which is used to build the project https://aka.ms/obpipelines/containers
  BLACK_OPTS: '-vv --diff -t py38 --check'

pool:
  vmImage: ubuntu-latest

extends:
  template: v2/OneBranch.Official.CrossPlat.yml@templates # https://aka.ms/obpipelines/templates
  parameters:
    cloudvault: # https://aka.ms/obpipelines/cloudvault
      enabled: false
    globalSdl: # https://aka.ms/obpipelines/sdl
      tsa:
        enabled: false # onebranch publish all sdl results to TSA. If TSA is disabled all SDL tools will forced into 'break' build mode.
      # credscan:
      #   suppressionsFile: $(Build.SourcesDirectory).configCredScanSuppressions.json
      binskim:
        break: true # always break the build on binskim issues in addition to TSA upload
      policheck:
        break: true # always break the build on policheck issues. You can disable it by setting to 'false'
      # suppression:
      #   suppressionFile: $(Build.SourcesDirectory).gdnglobal.g

      stages:
        - stage: test
          jobs:
          - job: Run Tests
            steps:
              - script: |
                  python -m pip install --upgrade pip    
                  python -m pip install pytest
                displayName: "Install dependencies"

              # this runs the unit tests
              - 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:
            # This builds the whl from the code repo using the path defined in workingDirectory
            - 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:
            # This copies the whl generated in the previous step to the artifact staging directory
            - task: CopyFiles@2
              inputs:
                SourceFolder: $(Build.SourcesDirectory)/src/framework/dist
                Contents: '**.whl'
                targetFolder: $(Build.ArtifactStagingDirectory)
              displayName: Copy to artifact staging

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

2

Answers


  1. You need to define a repository resource so that the pipeline knows where @templates is located.

    i.e.

    repositories:
    - repository: string # Required as first property. Alias for the repository.
      endpoint: string # ID of the service endpoint connecting to this repository.
      trigger: none | trigger | [ string ] # CI trigger for this repository, no CI trigger if skipped (only works for Azure Repos).
      name: string # repository name (format depends on 'type'; does not accept variables).
      ref: string # ref name to checkout; defaults to 'refs/heads/main'. The branch checked out by default whenever the resource trigger fires.
      type: string # Type of repository: git, github, githubenterprise, and bitbucket.
    

    Ref: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/resources-repositories-repository?view=azure-pipelines

    If the template is located in the same repository as the pipeline, you don’t need to specify @templates@templates would be referring to a repository resource named templates.

    Login or Signup to reply.
  2. In your pipeline you have this part:

    extends:
      template: v2/OneBranch.Official.CrossPlat.yml@templates
    

    Thing is that v2/OneBranch.Official.CrossPlat.yml@templates means:

    Take file v2/OneBranch.Official.CrossPlat.yml from the resource templates

    But I don’t see any definition of resource templates and any other resources at all.


    If we refer to the documentation:

    Azure Pipelines | Template types & usage

    # File: azure-pipelines.yml
    resources:
      repositories:
        - repository: templates # That is how you define resource `templates`
          type: git
          name: Contoso/BuildTemplates
          ref: refs/tags/v1 # You might want to pin it to a specific tag to avoid surprises.
    
    jobs:
    - template: v2/OneBranch.Official.CrossPlat.yml@templates  # Then you use resource `templates` here
    

    So, you need to:

    1. Define resource (repository) with the name templates.
    2. Refer to the file from it later using template: v2/OneBranch.Official.CrossPlat.yml@templates.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search