首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure管道从资源存储库中读取文件

Azure管道从资源存储库中读取文件
EN

Stack Overflow用户
提问于 2021-01-12 05:13:05
回答 1查看 1.6K关注 0票数 2

我在我的azure-pipelines模板中引用了一个存储库,如下所示:

代码语言:javascript
复制
resources:
  repositories:

    - repository: MyRepo
      type: git
      name: MyRepoName
      ref: MyRepoRef

我想知道是否有可能读取引用存储库中的文件内容,在此存储库中是另一个正在管道中执行的yaml。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-12 10:06:47

如果我们在管道中使用另一个repo,我们可以读取被引用存储库中的文件内容。我们可以参考此link了解更多详细信息

在我的测试中,项目名称是test,引用的存储库是test,当前存储库是sample,然后读取文件pull_request_template.md的内容

YAML构建定义:

代码语言:javascript
复制
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'

结果:

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65674610

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档