我在我的azure-pipelines模板中引用了一个存储库,如下所示:
resources:
repositories:
- repository: MyRepo
type: git
name: MyRepoName
ref: MyRepoRef我想知道是否有可能读取引用存储库中的文件内容,在此存储库中是另一个正在管道中执行的yaml。
发布于 2021-01-12 10:06:47
如果我们在管道中使用另一个repo,我们可以读取被引用存储库中的文件内容。我们可以参考此link了解更多详细信息
在我的测试中,项目名称是test,引用的存储库是test,当前存储库是sample,然后读取文件pull_request_template.md的内容
YAML构建定义:
trigger: none
resources:
repositories:
- repository: test
type: git
name: test/test
ref: master
steps:
#checkout referenced repository
- checkout: test
#List SourcesDirectory files
- task: Bash@3
inputs:
targetType: 'inline'
script: 'ls ''$(Build.SourcesDirectory)'''
#Read the contents of the file pull_request_template.md
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'Get-Content -Path $(Build.SourcesDirectory)\pull_request_template.md'结果:

https://stackoverflow.com/questions/65674610
复制相似问题