resources.repositories.repository 定義

repository キーワードを使うと、外部リポジトリを指定できます。 リポジトリ リソースを使用して、パイプライン内の追加のリポジトリを参照します。

repositories:
- repository: string # Required as first property. Alias for the repository.
  endpoint: string # ID of the service endpoint connecting to this repository.
  trigger: none | trigger | [ string ] # CI trigger for this repository, no CI trigger if skipped (only works for Azure Repos).
  name: string # repository name (format depends on 'type'; does not accept variables).
  ref: string # ref name to checkout; defaults to 'refs/heads/main'. The branch checked out by default whenever the resource trigger fires.
  type: string # Type of repository: git, github, githubenterprise, and bitbucket.
repositories:
- repository: string # Required as first property. Alias for the repository.
  endpoint: string # ID of the service endpoint connecting to this repository.
  trigger: none | trigger | [ string ] # CI trigger for this repository, no CI trigger if skipped (only works for Azure Repos).
  name: string # repository name (format depends on 'type'; does not accept variables).
  type: string # Type of repository: git, github, githubenterprise, and bitbucket.
  ref: string # ref name to checkout; defaults to 'refs/heads/main'. The branch checked out by default whenever the resource trigger fires. Does not accept variables.
repositories:
- repository: string # Required as first property. Alias for the repository.
  endpoint: string # ID of the service endpoint connecting to this repository.
  name: string # repository name (format depends on 'type'; does not accept variables).
  type: string # Type of repository: git, github, githubenterprise, and bitbucket.
  ref: string # ref name to checkout; defaults to 'refs/heads/main'. The branch checked out by default whenever the resource trigger fires. Does not accept variables.

この定義を参照する定義: resources.repositories

プロパティ

repository 文字列。 最初のプロパティとして必須。
指定したリポジトリのエイリアス。 使用できる値: [-_A-Za-z0-9]*。

endpoint 文字列。
このリポジトリに接続しているサービス エンドポイントの ID。

triggerトリガー
このリポジトリの CI トリガー。省略した場合は CI トリガーはありません。

重要

  • リポジトリ リソース トリガーは、Azure Repos Git リポジトリでのみサポートされます。
  • リポジトリ リソース トリガーでは、 はサポート batchされていません。

name 文字列。
リポジトリ名。 形式は 'type' によって異なります。は変数を受け入れません。

ref 文字列。
チェックアウトする ref 名。既定値は 'refs/head/メイン' です。 リソース トリガーが起動するたびに、ブランチは既定でチェックアウトされます。 テンプレート式がサポートされています

ref 文字列。
チェックアウトする ref 名。既定値は 'refs/head/メイン' です。 リソース トリガーが起動するたびに、ブランチは既定でチェックアウトされます。 変数は受け入れられません。

type 文字列。
リポジトリの種類: git、github、githubenterprise、bitbucket。

注釈

重要

リポジトリ リソースでは、 と refのパイプライン変数はname許可されません。 ワイルドカードはトリガーでサポートされています。

テンプレート式は、 プロパティでサポートされていますがref プロパティでは name サポートされていません。 ワイルドカードはトリガーでサポートされています。

重要

リポジトリ リソース トリガーは、Azure Repos Git リポジトリでのみサポートされています。 ブランチタグtriggerワイルドカードサポートなど、構文の詳細については、「トリガー定義」および「Git または TFS Git リポジトリAzure Reposビルド」を参照してください。

重要

batch は、リポジトリ リソース トリガーではサポートされていません。

パイプラインに別のリポジトリのテンプレートがある場合は、そのリポジトリについてシステムに知らせる必要があります。

パイプラインに別のリポジトリのテンプレートがある場合、またはサービス接続を必要とするリポジトリで複数のリポジトリのチェックアウトを使う場合は、システムにそのリポジトリについて認識させる必要があります。

種類

パイプラインでは、リポジトリの種類の値として gitgithubbitbucket がサポートされています。 種類 git は、Azure Repos Git リポジトリのことです。

  • を指定type: gitした場合、値は name Azure Repos Git リポジトリの名前を参照します。

    • パイプラインがリポジトリと同じ Azure DevOps プロジェクト (たとえば、 という名前 toolsのリポジトリ) にある場合は、 を使用して name: tools参照します。
    • パイプラインがリポジトリと同じ Azure DevOps organizationにあり、別の Azure DevOps プロジェクト (たとえば、 という名前ToolsProjectのプロジェクト) にある場合は、プロジェクト名でリポジトリ名name: ToolsProject/toolsを修飾する必要があります。
  • type: github を指定した場合、name の値は GitHub リポジトリの完全な名前であり、ユーザーまたは組織が含まれます。 たとえば name: Microsoft/vscode です。 GitHub リポジトリでは、承認のために GitHub サービス接続が必要です。

  • type: bitbucket を指定した場合、name の値は Bitbucket Cloud リポジトリの完全な名前であり、ユーザーまたは組織が含まれます。 たとえば name: MyBitbucket/vscode です。 Bitbucket Cloud リポジトリでは、承認のために Bitbucket Cloud サービス接続が必要です。

これらの型の詳細については、「 パイプラインで複数のリポジトリをチェックアウトする - リポジトリ リソース定義」を参照してください。

変数

各実行では、パイプライン リソースのメタデータを、定義済み変数の形式ですべてのジョブから使用できます。 <Alias> は、ユーザーがリポジトリ リソースに対して指定した識別子です。

resources.repositories.<Alias>.name
resources.repositories.<Alias>.ref
resources.repositories.<Alias>.type
resources.repositories.<Alias>.id
resources.repositories.<Alias>.url
resources.repositories.<Alias>.version

次の例では、common のエイリアスを持つリポジトリ リソースがあり、リポジトリ リソース変数には resources.repositories.common.* を使用してアクセスします。

resources:
  repositories:
    - repository: common
      type: git
      ref: main
      name: Repo

variables:
  ref: $[ resources.repositories.common.ref ]
  name: $[ resources.repositories.common.name ]
  id: $[ resources.repositories.common.id ]
  type: $[ resources.repositories.common.type ]
  url: $[ resources.repositories.common.url ]
  version: $[ resources.repositories.common.version ]

steps:
- bash: |
    echo "name = $(name)"
    echo "ref = $(ref)"
    echo "id = $(id)"
    echo "type = $(type)"
    echo "url = $(url)"
    echo "version = $(version)"

変数

各実行では、パイプライン リソースのメタデータを、定義済み変数の形式ですべてのジョブから使用できます。 <Alias> は、ユーザーがリポジトリ リソースに対して指定した識別子です。

resources.repositories.<Alias>.name
resources.repositories.<Alias>.ref
resources.repositories.<Alias>.type
resources.repositories.<Alias>.id
resources.repositories.<Alias>.url

次の例では、common のエイリアスを持つリポジトリ リソースがあり、リポジトリ リソース変数には resources.repositories.common.* を使用してアクセスします。

resources:
  repositories:
    - repository: common
      type: git
      ref: main
      name: Repo

variables:
  ref: $[ resources.repositories.common.ref ]
  name: $[ resources.repositories.common.name ]
  id: $[ resources.repositories.common.id ]
  type: $[ resources.repositories.common.type ]
  url: $[ resources.repositories.common.url ]

steps:
- bash: |
    echo "name = $(name)"
    echo "ref = $(ref)"
    echo "id = $(id)"
    echo "type = $(type)"
    echo "url = $(url)"

resources:
  repositories:
  - repository: common
    type: github
    name: Contoso/CommonTools
    endpoint: MyContosoServiceConnection

関連項目