jobs.deployment.strategy の定義

デプロイ戦略を使用すると、更新プログラムの配信方法を構成できます。

この定義を参照する定義: jobs.deployment

実装

実装 説明
戦略: runOnce デプロイ戦略を 1 回実行します。
戦略: ローリング ローリング デプロイ戦略。
戦略: カナリア カナリアデプロイ戦略。

解説

アプリケーションの更新プログラムをデプロイする場合は、更新プログラムの配信に使用する手法で次のことを行う必要があります。

  • 初期化を有効にする。
  • 更新プログラムをデプロイする。
  • 更新されたバージョンにトラフィックをルーティングする。
  • トラフィックのルーティング後に更新されたバージョンをテストする。
  • エラーが発生した場合は、最新の既知の適切なバージョンに復元する手順を実行する。

これを実現するには、デプロイ中にステップを実行するライフサイクル フックを使用します。 各ライフサイクル フックは、プール属性に応じて、エージェント ジョブまたはサーバー ジョブ (または今後はコンテナーまたは検証ジョブ) に解決されます。 既定では、ライフサイクル フックはデプロイ ジョブで指定されたプールを継承します。

デプロイ ジョブでは、 $(Pipeline.Workspace) system variable.

セルフホステッド エージェントを使用している場合は、ワークスペース クリーン オプションを使用して、デプロイ ワークスペースをクリーンできます。

  jobs:
  - deployment: deploy
    pool:
      vmImage: ubuntu-latest
      workspace:
        clean: all
    environment: staging

戦略: runOnce

runOnce 配置戦略では、各手順を 1 回実行して変更をロールアウトします。

strategy:
  runOnce: # RunOnce Deployment strategy.
    preDeploy: # Pre deploy hook for runOnce deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where pre deploy steps will run.
    deploy: # Deploy hook for runOnce deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where deploy steps will run.
    routeTraffic: # Route traffic hook for runOnce deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where route traffic steps will run.
    postRouteTraffic: # Post route traffic hook for runOnce deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where post route traffic steps will run.
    on: # On success or failure hook for runOnce deployment strategy.
      failure: # Runs on failure of any step.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where post on failure steps will run.
      success: # Runs on success of all of the steps.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where on success steps will run.

プロパティ

runOncejobs.deployment.strategy.runOnce
RunOnce 配置戦略。

解説

runOnce は最も簡単なデプロイ方法であり、すべてのライフ サイクル フック (つまり、preDeploydeployrouteTrafficpostRouteTraffic) が 1 回実行されます。 その後、on: success または on: failure が実行されます。

戦略: ローリング

ローリング デプロイでは、反復するたびに固定された一連の仮想マシン (ローリング セット) を対象に、アプリケーションの以前のバージョンのインスタンスがそのアプリケーションの新しいバージョンのインスタンスに置き換えられます。

strategy:
  rolling: # Rolling Deployment strategy.
    maxParallel: string # Maximum number of jobs running in parallel.
    preDeploy: # Pre deploy hook for rolling deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where pre deploy steps will run.
    deploy: # Deploy hook for rolling deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where deploy steps will run.
    routeTraffic: # Route traffic hook for rolling deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where route traffic steps will run.
    postRouteTraffic: # Post route traffic hook for rolling deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where post route traffic steps will run.
    on: # On success or failure hook for rolling deployment strategy.
      failure: # Runs on failure of any step.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where post on failure steps will run.
      success: # Runs on success of all of the steps.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where on success steps will run.

プロパティ

rollingjobs.deployment.strategy.rolling.
ローリング デプロイ戦略。

戦略: カナリア

カナリア展開戦略では、サーバーの小さなサブセットに変更をロールアウトします。

strategy:
  canary: # Canary Deployment strategy.
    increments: [ string ] # Maximum batch size for deployment.
    preDeploy: # Pre deploy hook for canary deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where pre deploy steps will run.
    deploy: # Deploy hook for canary deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where deploy steps will run.
    routeTraffic: # Route traffic hook for canary deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where route traffic steps will run.
    postRouteTraffic: # Post route traffic hook for canary deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where post route traffic steps will run.
    on: # On success or failure hook for canary deployment strategy.
      failure: # Runs on failure of any step.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where post on failure steps will run.
      success: # Runs on success of all of the steps.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where on success steps will run.

プロパティ

canaryjobs.deployment.strategy.canary
カナリアデプロイ戦略。

解説

カナリア デプロイ戦略は、新しいバージョンのアプリケーションのロールアウトに伴うリスクを軽減するのに役立つ高度なデプロイ戦略です。 この方法を使用すると、サーバーの小さなサブセットに対する変更を最初にロールアウトできます。 新バージョンへの信頼度が上がってきたら、インフラストラクチャ内のより多くのサーバーにリリースし、より多くのトラフィックをルーティングすることができます。

関連項目