I have created a new OneBuild Pipeline and associated a OneBuild.Buddy.yml
with it. But when trying to run validation here:
we get:
Validation: /.pipelines/OneBranch.Buddy.yml: No repository found by name templates
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
You need to define a
repository
resource so that the pipeline knows where@templates
is located.i.e.
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 namedtemplates
.In your pipeline you have this part:
Thing is that
v2/OneBranch.Official.CrossPlat.yml@templates
means: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
So, you need to:
templates
.template: v2/OneBranch.Official.CrossPlat.yml@templates
.