簡體   English   中英

帶有模板的 azure devops yaml 管道不會檢出引用的存儲庫

[英]azure devops yaml pipeline with template does not checkout referenced repository

我正在使用新的 Azure DevOps Yaml 多階段管道功能

我有一個要使用模板的 Azure DevOps yaml 管道文件。 我希望管道可以檢出 self 和另一個存儲庫。

由於某種原因, self repo 在運行時已經被檢出,但是 repo: pipelines 沒有被檢出,因此作業失敗(因為它需要的一些文件依賴項不存在。

這是我的模板的摘錄:

resources:
  repositories:
  - repository: self
  - repository: pipelines
    name: vstsproject/pipelines
    type: git
    source: pipelines

variables:
  # Container registry service connection established during pipeline creation
  imageRepository: 'vstsprojectweb'
  dockerfilePath: '$(Build.SourcesDirectory)/src/Dockerfile.CI'
  BuildConfiguration: 'Release'
  tag: '$(Build.BuildId)'  

stages:

- stage: 'PRD'
  jobs:
  - template: update-connection-string-db.yml@pipelines
    parameters:
      resourceGroup: 'application-DEV'
      DBSearchString: '###dbservername###'  

我做錯了什么?

我已經參考了這個微軟文檔

您不需要在資源(即 self)中引用鏈接的 repo,如果它是唯一的 repo,則默認情況下會在作業(不是部署作業)中檢出它,但是如果您有額外的 repos,那么您需要手動檢查它們(使用 -checkout: <name_of_repo>)。

所以就這樣做(PS:清理了一下,假設回購在同一個項目中):

resources:
  repositories:
  - repository: pipelines
    source: pipelines

variables:
  # Container registry service connection established during pipeline creation
  imageRepository: 'vstsprojectweb'
  dockerfilePath: '$(Build.SourcesDirectory)/src/Dockerfile.CI'
  BuildConfiguration: 'Release'
  tag: '$(Build.BuildId)'  

stages:

- stage: 'PRD'
  jobs:
  - checkout: self
  - checkout: pipelines
  - template: update-connection-string-db.yml@pipelines
    parameters:
      resourceGroup: 'application-DEV'
      DBSearchString: '###dbservername###'  

我最終將所有內容都放入同一個 repo 中,然后在工作中檢查self

那對我有用。

  jobs:
  - job: dbconnectionstring
    displayName: 'db connection string'
    pool: Windows
    steps:
    - checkout: self
    - template: templates/update-connection-string-db.yml

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM