steps.checkout 定義

を使用して checkout 、パイプラインがソース コードをチェックアウトする方法を構成します。

steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
  clean: string # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
  fetchDepth: string # Depth of Git graph to fetch.
  fetchTags: string # Set to 'true' to sync tags when fetching the repo, or 'false' to not sync tags. See remarks for the default behavior.
  lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
  persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
  submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
  path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
  condition: string # Evaluate this condition expression to determine whether to run this task.
  continueOnError: boolean # Continue running even on failure?
  displayName: string # Human-readable name for the task.
  target: string | target # Environment in which to run this task.
  enabled: boolean # Run this task when the job runs?
  env: # Variables to map into the process's environment.
    string: string # Name/value pairs
  name: string # ID of the step.
  timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
  retryCountOnTaskFailure: string # Number of retries if the task fails.
steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
  clean: string # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
  fetchDepth: string # Depth of Git graph to fetch.
  lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
  persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
  submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
  path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
  condition: string # Evaluate this condition expression to determine whether to run this task.
  continueOnError: boolean # Continue running even on failure?
  displayName: string # Human-readable name for the task.
  target: string | target # Environment in which to run this task.
  enabled: boolean # Run this task when the job runs?
  env: # Variables to map into the process's environment.
    string: string # Name/value pairs
  name: string # ID of the step.
  timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
  retryCountOnTaskFailure: string # Number of retries if the task fails.
steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
  clean: string # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
  fetchDepth: string # Depth of Git graph to fetch.
  lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
  persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
  submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
  path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
  condition: string # Evaluate this condition expression to determine whether to run this task.
  continueOnError: boolean # Continue running even on failure?
  displayName: string # Human-readable name for the task.
  target: string | target # Environment in which to run this task.
  enabled: boolean # Run this task when the job runs?
  env: # Variables to map into the process's environment.
    string: string # Name/value pairs
  name: string # ID of the step.
  timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
steps:
- checkout: string # Required as first property. Whether or not to check out the repository containing this pipeline definition.
  clean: string # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
  fetchDepth: string # Depth of Git graph to fetch.
  lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
  persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
  submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
  path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
  condition: string # Evaluate this condition expression to determine whether to run this task.
  continueOnError: boolean # Continue running even on failure?
  displayName: string # Human-readable name for the task.
  enabled: boolean # Run this task when the job runs?
  env: # Variables to map into the process's environment.
    string: string # Name/value pairs
  name: string # ID of the step.
  timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
steps:
- checkout: string # Required as first property. Whether or not to check out the repository containing this pipeline definition.
  clean: string # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
  fetchDepth: string # Depth of Git graph to fetch.
  lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
  persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
  submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
  condition: string # Evaluate this condition expression to determine whether to run this task.
  continueOnError: boolean # Continue running even on failure?
  displayName: string # Human-readable name for the task.
  enabled: boolean # Run this task when the job runs?
  env: # Variables to map into the process's environment.
    string: string # Name/value pairs
  name: string # ID of the step.
  timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.

この定義を参照する定義: ステップ

プロパティ

checkout 文字列。 最初のプロパティとして必須。
指定したリポジトリのチェックアウトを構成します。 、none、リポジトリ名、またはリポジトリ リソースを指定selfします。 詳しくは、「パイプラインで複数のリポジトリをチェックアウトする」をご覧ください。

注意

ステップが存在しないcheckout場合、既定では と にjobs.job.step.checkoutnone設定jobs.deployment.steps.checkoutされますself

checkout 文字列。 最初のプロパティとして必須。
このパイプライン定義を含むリポジトリをチェックするかどうか。 self または none を指定します。

clean 文字列。
true の場合は、フェッチする前に git クリーン -ffdx の後に git reset --hard HEADを実行します。 true |False。

fetchDepth 文字列。
フェッチする Git グラフの深さ。

fetchTags 文字列。
リポジトリをフェッチするときにタグを同期するには 'true' に設定し、タグを同期しない場合は 'false' に設定します。 既定の動作については、「解説」を参照してください。

lfs 文字列。
Git-LFS ファイルをダウンロードするには、'true' に設定します。 既定では、ダウンロードされません。

persistCredentials 文字列。
最初のフェッチ後に Git 構成で OAuth トークンを残すには、'true' に設定します。 既定値は、そのままにしない場合です。

submodules 文字列。
1 レベルのサブモジュールの場合は 'true' に、サブモジュールのサブモジュールを取得するには 'recursive' に設定します。 既定では、サブモジュールはフェッチされません。

path 文字列。
リポジトリを配置する場所。 ルート ディレクトリは $(Pipeline.Workspace) です。

condition 文字列。
この条件式を評価して、このタスクを実行するかどうかを判断します。

continueOnErrorboolean
失敗しても実行を続けますか?

displayName 文字列。
タスクの人間が判読できる名前。

targetターゲット
このタスクを実行する環境。

enabledboolean
ジョブの実行時にこのタスクを実行しますか?

env 文字列ディクショナリ。
プロセスの環境にマップする変数。

name 文字列。
ステップの ID。 使用できる値: [-_A-Za-z0-9]*。

timeoutInMinutes 文字列。
サーバーによって強制終了されるまで、このタスクが完了するまでの時間。

注意

パイプラインは、ジョブ レベルのタイムアウトで構成できます。 ステップが完了する前にジョブ・レベルのタイムアウト間隔が経過すると、ステップが長い timeoutInMinutes 間隔で構成されている場合でも、実行中のジョブ (ステップを含む) が終了します。 詳細については、「 タイムアウト」を参照してください。

retryCountOnTaskFailure 文字列。
タスクが失敗した場合の再試行回数。

解説

浅いフェッチ

重要

2022 年 9 月の Azure DevOps スプリント 209 更新後に作成された新しいパイプラインでは、既定で [浅いフェッチ] が有効になっており、深さが 1 で構成されています。 以前は、既定では浅いフェッチは行われませんでした。 パイプラインをチェックするには、パイプライン設定 UI[シャロー フェッチ] 設定を表示します。

シャロー フェッチを無効にするには、次の 2 つのオプションのいずれかを実行します。

  • パイプライン設定 UI[シャロー フェッチ] オプションを無効にします。
  • ステップで明示的に設定 fetchDepth: 0 します checkout

パイプラインのフェッチの深さを構成するには、ステップで プロパティをfetchDepthcheckout設定するか、パイプライン設定 UI[シャロー フェッチ] 設定を構成します。

注意

checkout ステップで fetchDepth を明示的に設定した場合、その設定はパイプライン設定 UI で構成された設定よりも優先されます。 fetchDepth: 0 を設定すると、すべての履歴がフェッチされ、[浅いフェッチ] 設定はオーバーライドされます。

Clean プロパティ

プロパティがclean未設定の場合、既定値は YAML パイプラインの UI 設定のクリーン設定によって構成されます。既定値は true に設定されています。 checkout を使って利用できるクリーニング オプションに加えて、ワークスペースでクリーニングを構成することもできます。 ワークスペースとクリーン オプションの詳細については、「ジョブ」のワークスペースのトピックを参照してください。

タグを同期する

チェックアウト ステップでは、Git リポジトリの内容をフェッチするときに --tags オプションを使用します。 これにより、サーバーはすべてのタグと、それらのタグが指すすべてのオブジェクトをフェッチします。 これにより、特に多数のタグを持つ大規模なリポジトリがある場合に、パイプラインでタスクを実行する時間が長くなります。 さらに、チェックアウト ステップでは、浅いフェッチ オプションを有効にした場合でもタグが同期されるため、逆効果になる可能性があります。 Git リポジトリからフェッチまたはプルされるデータの量を減らすために、タグの同期の動作を制御するための新しいオプションが Microsoft によってチェックアウトに追加されました。 このオプションは、クラシック パイプラインと YAML パイプラインの両方で使用できます。

リポジトリをチェックアウトするときにタグを同期するかどうかは、YAML で fetchTags プロパティを設定するか、UI で [タグの同期] 設定を構成することで構成できます。

YAML で設定を構成するには、fetchTags プロパティを設定します。

steps:
- checkout: self
  fetchTags: true

パイプライン UI で設定を構成するには、YAML パイプラインを編集し、[その他のアクション]、[トリガー]、[YAML]、[ソースの取得]、[チェック]、[タグの同期] チェック ボックスをオフにします。 詳細については、「タグの 同期」を参照してください。

既定の動作

  • 2022 年 9 月にリリースされた Azure DevOps スプリント 209 のリリース前に作成された既存のパイプラインの場合、タグの同期の既定値は、[タグの同期] オプションが追加される前の既存の動作 (true) と同じままです。
  • Azure DevOps スプリント リリース 209 の後に作成された新しいパイプラインの場合、タグの同期の既定値は false です。

重要

UI の 同期タグ の設定が true の場合、YAML 内の fetchTags: false ステートメントよりも優先されます。 UI で [タグの同期] が true に設定されている場合、YAML で が false に設定されていても fetchTags 、タグは同期されます。

ソースがまったく同期されないようにするには:

steps:
- checkout: none

注意

ローカル サービス アカウントでエージェントを実行していて、git 操作を使うか git サブモジュールを読み込むことによって現在のリポジトリを変更したい場合は、プロジェクト コレクション ビルド サービス アカウント ユーザーに適切なアクセス許可を付与します。

- checkout: self
  submodules: true
  persistCredentials: true

パイプラインで複数のリポジトリをチェックアウトするには、複数の checkout ステップを使います。

- checkout: self
- checkout: git://MyProject/MyRepo
- checkout: MyGitHubRepo # Repo declared in a repository resource

詳しくは、「パイプラインで複数のリポジトリをチェックアウトする」をご覧ください。

関連項目