resources.pipelines.pipeline definition

成果物を生成する Azure Pipeline がある場合は、パイプライン リソースを定義することで、パイプラインで成果物を使用できます。 Azure DevOps Server 2020 以降では、パイプライン リソースを使用してパイプライン完了トリガーを有効にすることもできます。

pipelines:
- pipeline: string # Required as first property. ID of the pipeline resource.
  project: string # Project for the source; defaults to current project.
  source: string # Name of the pipeline that produces the artifact.
  version: string # The pipeline run number to pick the artifact, defaults to latest pipeline successful across all stages; used only for manual or scheduled triggers.
  branch: string # Branch to pick the artifact. Optional; defaults to all branches, used only for manual or scheduled triggers.
  tags: [ string ] # List of tags required on the pipeline to pickup default artifacts. Optional; used only for manual or scheduled triggers.
  trigger:  # Specify none to disable, true to include all branches, or use the full syntax as described in the following examples.
    enabled: boolean # Whether the trigger is enabled; defaults to true.
    branches: branches # Branches to include or exclude for triggering a run.
    stages: [ string ] # List of stages that when matched will trigger the pipeline.
    tags: [ string ] # List of tags that when matched will trigger the pipeline.
pipelines:
- pipeline: string # Required as first property. ID of the pipeline resource.
  project: string # Project for the source; defaults to current project.
  source: string # Name of the pipeline that produces the artifact.
  version: string # The pipeline run number to pick the artifact, defaults to latest pipeline successful across all stages; used only for manual or scheduled triggers.
  branch: string # Branch to pick the artifact. Optional; defaults to all branches, used only for manual or scheduled triggers.
  tags: [ string ] # List of tags required on the pipeline to pickup default artifacts. Optional; used only for manual or scheduled triggers.
  trigger:  # Specify none to disable, true to include all branches, or use the full syntax as described in the following examples.
    enabled: boolean # Whether the trigger is enabled; defaults to true.
    branches: branches # Branches to include or exclude for triggering a run.
pipelines:
- pipeline: string # Required as first property. ID of the pipeline resource.
  project: string # Project for the source; defaults to current project.
  source: string # Name of the pipeline that produces the artifact.
  version: string # The pipeline run number to pick the artifact, defaults to latest pipeline successful across all stages; used only for manual or scheduled triggers.
  branch: string # Branch to pick the artifact. Optional; defaults to all branches, used only for manual or scheduled triggers.

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

プロパティ

pipeline 文字列。 最初のプロパティとして必須。
パイプライン リソースの ID。 使用できる値: [-_A-Za-z0-9]*

project 文字列。
ソースのプロジェクト。は既定で現在のプロジェクトに設定されます。

source 文字列。
成果物を生成するパイプラインの名前。 パイプラインがフォルダーに含まれている場合は、先頭 \の を含むフォルダー名を含めます (例: \security pipelines\security-lib-ci)。 このプロパティでは大文字と小文字は区別されず、名前にスペースが含まれている場合は引用符は必要ありません。 同じ名前の複数のパイプラインがある場合は、フォルダー パスを指定する必要があります。

version 文字列。
成果物を選択するパイプライン実行番号。既定値は、すべてのステージで成功した最新のパイプラインです。は、手動トリガーまたはスケジュールされたトリガーにのみ使用されます。

branch 文字列。
成果物を選択するブランチ。 オプション;は既定ですべてのブランチに設定され、手動またはスケジュールされたトリガーにのみ使用されます。

tags 文字列リスト。
既定の成果物を取得するためにパイプラインで必要なタグの一覧。 オプション;は、手動トリガーまたはスケジュールされたトリガーにのみ使用されます。

triggerresources.pipelines.pipeline.trigger
無効にする場合は none を指定し、すべてのブランチを含める場合は true を指定するか、次の例で説明するように完全な構文を使用します。

注釈

Note

pipeline: は、パイプライン リソースの名前を指定します。 パイプライン リソース変数を使用する場合や成果物をダウンロードする場合など、パイプラインの他の部分からパイプライン リソースを参照する場合は、ここで定義されているラベルを使用します。

パイプライン リソース トリガーの と tags の詳細stagesについては、「パイプライン完了トリガー」を参照してください。

パイプライン リソース トリガーの詳細については、「 パイプライン完了トリガー」を参照してください。

パイプライン リソース トリガーの構文

注意

パイプライン完了トリガーでは、 手動ビルドとスケジュールされたビルドの既定のブランチ 設定を使用して、別のパイプラインの完了の結果としてパイプラインを実行するかどうかを判断するときに評価する YAML パイプラインのブランチ フィルターのブランチのバージョンを決定します。 既定では、この設定はリポジトリの既定のブランチを指します。 詳細については、「 パイプライン完了トリガー - ブランチに関する考慮事項」を参照してください。

パイプライン リソースでトリガーを定義するには、いくつかの方法があります。 参照されるパイプラインの実行が完了したときに実行をトリガーするには、 を使用 trigger: trueします。

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger: true

パイプライン リソース トリガーを無効にするには、 の none値を指定します。

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger: none

ブランチ フィルターを構成するには、完全な構文を使用します。 ブランチ フィルターは、含めるブランチの一覧として、または除外するブランチのリストと組み合わせて含めるブランチのリストとして指定できます。

含めるブランチと除外するブランチの一覧を指定するには、次の構文を使用します trigger

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger:
      branches:
        include:
        - main
        - develop
        - features/*
        exclude:
        - features/experimental/*

含めるブランチの一覧を除外なしで指定するには、値を exclude 省略するか、次の構文を使用して、 の後に直接 branches含めるブランチの一覧を指定します。

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger:
      branches:
      - main
      - develop

ステージまたはタグでフィルター処理するには、次の構文を使用します trigger

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline
    trigger:
      branches: # Branches to include
      tags: # List of tags that when matched will trigger the pipeline. 
      - release25
      stages: # List of stages that when complete will trigger the pipeline. 
      - build

詳しくは、パイプライン完了トリガーに関する記事をご覧ください。

重要

リソース トリガーを定義するとき、そのパイプライン リソースが現在のパイプラインと同じリポジトリからのものである場合、トリガーはイベントが発生したのと同じブランチとコミットに従います。 一方、パイプライン リソースが別のリポジトリのものである場合は、現在のパイプラインは、[手動のビルドとスケジュールされたビルドの既定のブランチ] の設定で指定されているブランチでトリガーされます。 詳しくは、パイプライン完了トリガーのブランチに関する考慮事項に関する記事をご覧ください。

定義済み変数としてのパイプライン リソース メタデータ

各実行では、パイプライン リソースのメタデータは、次の定義済み変数としてすべてのジョブで使用できます。 これらの変数は実行時にパイプラインで使用できるため、パイプラインのコンパイル時に評価される テンプレート式では使用できません。

resources.pipeline.<Alias>.projectName
resources.pipeline.<Alias>.projectID
resources.pipeline.<Alias>.pipelineName
resources.pipeline.<Alias>.pipelineID
resources.pipeline.<Alias>.runName
resources.pipeline.<Alias>.runID
resources.pipeline.<Alias>.runURI
resources.pipeline.<Alias>.sourceBranch
resources.pipeline.<Alias>.sourceCommit
resources.pipeline.<Alias>.sourceProvider
resources.pipeline.<Alias>.requestedFor
resources.pipeline.<Alias>.requestedForID

重要

projectName パイプライン リソースに値が指定されていない場合は、 が変数に project 存在しません。 プロパティは project 、同じプロジェクト内のパイプラインを参照するパイプライン リソースでは省略可能ですが、必要に応じて指定できます。

をパイプライン リソースの ID に置き換えます <Alias> 。 次のパイプライン リソースの場合、アクセス runID する変数は です resources.pipeline.source-pipeline.runID

resources:
  pipelines:
  - pipeline: source-pipeline
    source: TriggeringPipeline

パイプラインリソースの 1 つによってパイプラインがトリガーされると、前の一覧の変数に加えて、次の変数が設定されます。

変数
Build.Reason ResourceTrigger
Resources.TriggeringAlias 前の例のような source-pipeline パイプライン リソースの名前。
Resource.TriggeringCategory pipeline

次の例には、2 つのパイプライン リソースがあります。

resources:
 pipelines:
   - pipeline: source-pipeline
     source: PipelineTriggerSource
     project: FabrikamFiber
     trigger: true
   - pipeline: other-project-pipeline
     source: PipelineTriggerFromOtherProject
     project: FabrikamRepo
     trigger: true

trigger: none # Only trigger with pipeline resource trigger

pool:
  vmImage: ubuntu-latest

- bash: echo $(resources.pipeline.source-pipeline.projectName)
- bash: printenv | sort

このパイプラインが実行されると、最初bashのタスクは という名前source-pipelineのパイプライン リソースの を出力projectNameします。これは ですFabrikamFiber

2 番目 bash のタスクは、このセクションで説明するパイプライン リソース変数を含め、タスクで使用できるすべての環境変数を出力します。 環境変数の一覧表示は通常、運用パイプラインでは行われませんが、トラブルシューティングに役立つ場合があります。 この例では、2 つのパイプライン リソースがあり、出力には次の 2 行が含まれています。

RESOURCES_PIPELINE_OTHER-PROJECT-PIPELINE_PROJECTNAME=FabrikamRepo
RESOURCES_PIPELINE_SOURCE-PIPELINE_PROJECTNAME=FabrikamFiber

注意

システム変数とユーザー定義変数は、プラットフォームの環境変数として挿入されます。 変数が環境変数に変換されると、変数名は大文字になり、ピリオドはアンダースコアになります。 たとえば、変数名 any.variable は になります ANY_VARIABLE

変数と変数構文の使用の詳細については、「変数の 構文について」、「 条件を指定する」、「 」を参照してください。

download タスクを使うことで、パイプライン リソースから成果物を使用できます。 steps.download キーワード (keyword)を参照してください。

resources:
  pipelines:
  - pipeline: MyAppA
    source: MyCIPipelineA
  - pipeline: MyAppB
    source: MyCIPipelineB
    trigger: true
  - pipeline: MyAppC
    project:  DevOpsProject
    source: MyCIPipelineC
    branch: releases/M159
    version: 20190718.2
    trigger:
      branches:
        include:
        - main
        - releases/*
        exclude:
        - users/*

関連項目