共用方式為


jobs.deployment.strategy 定義

部署策略可讓您設定更新的傳遞方式。

參考此定義的定義:jobs.deployment

實作

實施 說明
策略:runOnce 執行一次部署策略。
策略:滾動 滾動部署策略。
策略:canary Canary 部署策略。

備註

當您部署應用程式更新時,請務必使用傳遞更新的技術:

  • 啟用初始化。
  • 部署更新。
  • 將流量路由至更新的版本。
  • 在路由流量後測試更新的版本。
  • 如果失敗,請執行步驟以還原至最後一個已知的良好版本。

我們會使用可在部署期間執行步驟的生命週期攔截來達成此目的。 每個生命周期攔截都會根據集區屬性解析為代理程式作業或伺服器作業(或未來的容器或驗證作業)。 根據預設,生命周期攔截會繼承部署作業所指定的集區。

部署作業使用 $(Pipeline.Workspace) system variable.

如果您使用自我裝載的代理程式,您可以使用工作區清除選項來清除部署工作區。

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

策略:runOnce

runOnce 部署策略會執行每個步驟一次來推出變更。

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.

性能

runOnce jobs.deployment.strategy.runOnce
RunOnce 部署策略。

備註

runOnce 是最簡單的部署策略,即 preDeploydeployrouteTrafficpostRouteTraffic等所有生命周期攔截都會執行一次。 然後,會執行 on: successon: 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.

性能

rolling jobs.deployment.strategy.rolling
滾動部署策略。

策略:Canary

Canary 部署策略會推出對一小部分伺服器所做的變更。

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.

性能

canary jobs.deployment.strategy.canary
Canary 部署策略。

備註

Canary 部署策略是進階部署策略,可協助降低推出新版本應用程式所涉及的風險。 藉由使用此策略,您可以先對一小部分的伺服器推出變更。 隨著您對新版本的信心增加,便能發行到基礎結構中的更多伺服器,然後將更多流量路由到該版本。

另請參閱