Could not get the latest source version for repository *** hosted on Azure Repos using ref ***
insights Stats
Data analytics, application development with Microsoft Azure cloud platform.
When creating Azure pipeline, it is common to checkout other repositories on Azure DevOps. In some cases, you may encounter the following error:
Could not get the latest source version for repository *** hosted on Azure Repos using ref ***
Reproduce the error
You can reproduce the error using the following steps:
- Create a branch with name like
test-branch
. - In Azure DevOps pipeline, add the following section:
resources:
repositories:
- repository: build_template_repo
type: git
name: kontext/build_template ref: test_branch
jobs:
- template: azure-pipelines-template.yml@build_template_repo - Run the build pipeline.
The error will show up because there is no branch named test_branch
existing in my project.
Resolution
To fix this issue, you will need to rename the branch name to remove hyphen, for example, replacing it with test_branch
. However I've tested and this is not causing any issues. For example, the following pipeline works fine:
# Starter pipeline # Start with a minimal pipeline that you can customize to build and deploy your code. # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml pool: vmImage: ubuntu-latest resources: repositories: - repository: my-repo type: git name: kontext/test ref: feature/test-branch steps: - script: echo Hello, world! displayName: 'Run a one-line script' - script: | echo Add other tasks to build, test, and deploy your project. echo See https://aka.ms/yaml displayName: 'Run a multi-line script' - checkout: my-repo
Thus the normal cause of this error is mainly because the repository name or reference names don't exist in your Azure project. Make sure you have referenced the correct repo, branch, tag and commit names in your pipeline.
References
Pipeline template - could not get latest source version - Visual Studio Feedback
Check out multiple repositories in your pipeline - Azure Pipelines | Microsoft Docs