我正在像这样在我的 azure-pipelines 模板中引用一个存储库:
resources:
repositories:
- repository: MyRepo
type: git
name: MyRepoName
ref: MyRepoRef
我想知道是否可以读取引用存储库中文件的内容,该存储库中是另一个正在管道中执行的 yaml。
答案 0 :(得分:1)
如果我们在管道中使用另一个存储库,我们可以读取引用存储库中文件的内容。我们可以参考此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'
结果: