checkout
を使用して、パイプラインがソース コードをチェックアウトする方法を構成します。
steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
clean: true | false # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
fetchDepth: string # Depth of Git graph to fetch.
fetchFilter: string # Filter Git history.
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).
sparseCheckoutDirectories: string # Directories for sparse checkout in cone mode and prioritized over sparseCheckoutPatterns if both properties are provided.
sparseCheckoutPatterns: string # Patterns for sparse checkout in non-cone mode that are ignored if sparseCheckoutDirectories is provided.
workspaceRepo: true | false # When true, use the repository root directory as the default working directory for the pipeline. The default is false.
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: true | false # 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: true | false # 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: true | false # 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.
この定義を参照する定義: 手順
プロパティ
checkout
文字列。 最初のプロパティとして必要です。
指定したリポジトリのチェックアウトを構成します。
self
、none
、リポジトリ名、またはリポジトリ リソース を指定します。 詳細については、「パイプライン内の複数のリポジトリをチェックアウトする」を参照してください。
手記
checkout
ステップが存在しない場合は、既定で self
に jobs.job.step.checkout
し、none
に jobs.deployment.steps.checkout
します。
clean
文字列。
true の場合は、フェッチする前に git clean -ffdx を実行してから git reset --hard HEAD を実行します。 true |偽。
fetchDepth
文字列。
フェッチする Git グラフの深さを します。
fetchFilter
文字列。
fetchFilter
を使用して、部分的な複製のために Git 履歴をフィルター処理します。
fetchFilter
設定では、ツリーレス フェッチと BLOB レス フェッチがサポートされます。 ツリーレス フェッチの場合は、fetchFilter: tree:0
を指定し、BLOB レス フェッチを指定するには、fetchFilter: blob:none
を指定します。 既定値はフィルター処理なしです。
fetchTags
文字列。
リポジトリをフェッチするときにタグを同期するには 'true' に設定し、タグを同期しない場合は 'false' に設定します。 既定の動作については、「解説」を参照してください。
lfs
文字列。
'true' に設定すると、Git-LFS ファイルがダウンロードされます。 既定では、ダウンロードされません。
persistCredentials
文字列。
最初のフェッチ後に OAuth トークンを Git 構成に残すには、'true' に設定します。 既定値は、そのままにしません。
submodules
文字列。
サブモジュールのサブモジュールを取得するには、単一レベルのサブモジュールに対して 'true' に設定するか、'recursive' に設定します。 既定では、サブモジュールはフェッチされません。
path
文字列。
リポジトリを配置する場所を指定します。 ルート ディレクトリは $(Pipeline.Workspace) です。 既定では、このフォルダーはエージェントの作業ディレクトリ構造の下にある必要があります。 エージェント作業ディレクトリの外部にパスを設定するには、AZP_AGENT_ALLOW_WORK_DIRECTORY_REPOSITORIES
という名前のパイプライン変数を true に設定し、チェックアウト パスの開始時にプレフィックス ../
を使用します。 エージェント バージョン 3.230.0 以降でサポートされています。
sparseCheckoutDirectories
文字列。
ディレクトリ一致を使用して円錐モードでスパース チェックアウトを有効にするディレクトリを指定します。 スペースを使用して複数のディレクトリを分離します。 Git 2.25 以降では、エージェント バージョン 3.253.0/4.253.0 以降でサポートされています。
- checkout: repo
sparseCheckoutDirectories: src
sparseCheckoutDirectories
と sparseCheckoutPatterns
の両方が設定されている場合、sparseCheckoutDirectories
が使用され、sparseCheckoutPatterns
の設定は無視されます。
スパース チェックアウトの詳細については、「スパース チェックアウトを使用して monorepo のサイズを縮小する」を参照してください。
sparseCheckoutPatterns
文字列。
パターン マッチングを使用して非コーン モードでスパース チェックアウトを有効にするパターンを指定します。 スペースを使用して複数のパターンを分離します。 Git 2.25 以降では、エージェント バージョン 3.253.0/4.253.0 以降でサポートされています。
- checkout: repo
sparseCheckoutPatterns: /* !/img
sparseCheckoutDirectories
と sparseCheckoutPatterns
の両方が設定されている場合、sparseCheckoutDirectories
が使用され、sparseCheckoutPatterns
の設定は無視されます。
スパース チェックアウトの詳細については、「スパース チェックアウトを使用して monorepo のサイズを縮小する」を参照してください。
workspaceRepo
文字列。
true の場合は、パイプラインの既定の作業ディレクトリとしてリポジトリのルート ディレクトリを使用します。 既定値は false です。
condition
文字列。
この条件式を評価して、このタスクを実行するかどうかを決定します。
ブールを continueOnError
します。
障害が発生しても実行を続行しますか?
displayName
文字列。
タスクの人間が判読できる名前を します。
ターゲットを target
します。
このタスクを実行する環境です。
ブールを enabled
します。
ジョブの実行時にこのタスクを実行しますか?
文字列ディクショナリ env
します。
変数を使用して、プロセスの環境にマップします。
name
文字列。
ステップの ID。 使用できる値: [-_A-Za-z0-9]*。
timeoutInMinutes
文字列。
このタスクが完了するまで待機してから、サーバーによって強制終了されるまでの時間を指定します。
手記
パイプラインは、ジョブ レベルのタイムアウトで構成できます。 ステップが完了する前にジョブ レベルのタイムアウト間隔が経過すると、ステップが長い timeoutInMinutes
間隔で構成されている場合でも、実行中のジョブ (ステップを含む) が終了します。 詳細については、「タイムアウト」を参照してください。
retryCountOnTaskFailure
文字列。
タスクが失敗した場合の再試行回数。
備考
浅いフェッチ
手記
一部の組織では、2022 年 9 月の Azure DevOps スプリント 209 更新プログラムの後に作成された新しいパイプライン、既定で簡易フェッチ が有効になり、深さが 1 で構成。 以前は、既定値はシャロー フェッチではありません。
パイプラインを確認するには、パイプライン設定 UIで の簡易フェッチ 設定を表示します。
シャロー フェッチを無効にするには、次の 2 つのオプションのいずれかを実行できます。
- パイプライン設定 UIで、の [簡易フェッチ] オプションを無効にします。
-
fetchDepth: 0
ステップでcheckout
を明示的に設定します。
パイプラインのフェッチ深度を構成するには、fetchDepth
ステップで checkout
プロパティを設定するか、パイプライン設定 UIで Shallow fetch 設定を構成します。
手記
fetchDepth
ステップで checkout
を明示的に設定した場合、その設定はパイプライン設定 UI で構成された設定よりも優先されます。
fetchDepth: 0
設定すると、すべての履歴がフェッチされ、シャロー フェッチの 設定がオーバーライドされます。
Clean プロパティ
clean
プロパティが設定されていない場合、既定値は、既定で true に設定されている YAML パイプラインの UI 設定の クリーン 設定によって構成されます。
checkout
を使用して使用できるクリーニング オプションに加えて、ワークスペースでクリーニングを構成することもできます。 ワークスペースとクリーン オプションの詳細については、「ジョブ」の「ワークスペースの」トピックを参照してください。
タグの同期
チェックアウト手順では、Git リポジトリの内容をフェッチするときに、--tags
オプションを使用します。 これにより、サーバーはすべてのタグと、それらのタグによって指されているすべてのオブジェクトをフェッチします。 これにより、特に多数のタグを持つ大規模なリポジトリがある場合に、パイプラインでタスクを実行する時間が長くなります。 さらに、チェックアウト ステップでは、シャロー フェッチ オプションを有効にした場合でもタグが同期されるため、その目的が失われる可能性があります。 Git リポジトリからフェッチまたはプルされるデータの量を減らすために、Microsoft はタグの同期動作を制御するためのチェックアウトの新しいオプションを追加しました。 このオプションは、クラシック パイプラインと YAML パイプラインの両方で使用できます。
リポジトリをチェックアウトするときにタグを同期するかどうかを YAML で構成するには、fetchTags
プロパティを設定し、UI で 同期タグ 設定を構成します。
YAML で設定を構成するには、fetchTags
プロパティを設定します。
steps:
- checkout: self
fetchTags: true
パイプライン UI で設定を構成するには、YAML パイプラインを編集し、[その他のアクション]、[ トリガー] 、[ YAML] 、[ ソース の取得] の順に選択し、[ 同期タグ] チェック ボックスをオンまたはオフにします。 詳細については、「同期タグの」を参照してください。
既定の動作
- 2022 年 9 月にリリースされた Azure DevOps sprint 209のリリース前に作成された既存のパイプラインの場合、タグの同期の既定値は、同期タグ オプションが追加される前の既存の動作 (
true
) と同じです。 - Azure DevOps スプリント リリース 209 の後に作成された新しいパイプラインの場合、タグの同期の既定値は
false
です。
大事な
UI の 同期タグ true の設定は、YAML の fetchTags: false
ステートメントよりも優先されます。
同期タグ が UI で true に設定されている場合、YAML で fetchTags
が false に設定されている場合でもタグが同期されます。
例
checkout
には 3 つのオプションがあります。 既定では、Azure DevOps はジョブの self
を使用して現在のリポジトリをチェックアウトします。
none
設定すると、リポジトリはチェックアウトされません。別のリポジトリを指定した場合、そのリポジトリはチェックアウトされます。別のリポジトリをチェックアウトするには、最初に リポジトリ リソースとして設定します。
# Checkout the current repository
steps:
- checkout: self
# Prevent checking out any source code
steps:
- checkout: none
# Checkout a different repository
steps:
- checkout: my-other-repo
ソースの同期をまったく回避するには:
steps:
- checkout: none
手記
ローカル サービス アカウントでエージェントを実行していて、git 操作を使用するか Git サブモジュールを読み込んで現在のリポジトリを変更する場合は、Project Collection Build Service Accounts ユーザーに適切なアクセス許可を付与します。
- checkout: self
submodules: true
persistCredentials: true
パイプライン内の複数のリポジトリをチェックアウトするには、複数の checkout
手順を使用します。
- checkout: self
- checkout: git://MyProject/MyRepo
- checkout: MyGitHubRepo # Repo declared in a repository resource
詳細については、「パイプライン内の複数のリポジトリをチェックアウトする」を参照してください。
関連項目
- サポートされているソース リポジトリ を する