Share via


definição jobs.deployment.strategy

Uma estratégia de implantação permite configurar como a atualização é entregue.

Definições que fazem referência a essa definição: jobs.deployment

Implementações

Implementação Descrição
estratégia: runOnce Execute uma estratégia de implantação uma vez.
estratégia: rolando Estratégia de implantação sem interrupção.
estratégia: canário Estratégia de implantação canário.

Comentários

Quando você está implantando atualizações de aplicativos, é importante que a técnica usada para entregar a atualização seja:

  • Habilitar a inicialização.
  • Implantar a atualização.
  • Encaminhar o tráfego para a versão atualizada.
  • Testar a versão atualizada após o roteamento do tráfego.
  • Em caso de falha, execute as etapas para restaurar para a última versão boa conhecida.

Conseguimos isso usando ganchos de ciclo de vida que podem executar etapas durante a implantação. Cada um dos ganchos do ciclo de vida é resolvido em um trabalho de agente ou em um trabalho de servidor (ou em um contêiner ou trabalho de validação no futuro), dependendo do atributo de pool. Por padrão, os ganchos de ciclo de vida herdarão o pool especificado pelo trabalho de implantação.

Os trabalhos de implantação usam o $(Pipeline.Workspace) system variable.

Se você estiver usando agentes auto-hospedados, poderá usar o workspace limpo opções para limpo seu workspace de implantação.

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

estratégia: runOnce

A estratégia de implantação runOnce implementa alterações executando cada uma de suas etapas uma vez.

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.

Propriedades

runOncejobs.deployment.strategy.runOnce.
Estratégia de implantação do RunOnce.

Comentários

runOnce é a estratégia de implantação mais simples, em que todos os ganchos de ciclo de vida, especificamente preDeploydeploy, routeTraffic e postRouteTraffic, são executados uma vez. Depois, on: success ou on: failure é executado.

estratégia: rolando

uma implantação sem interrupção substitui as instâncias da versão anterior de um aplicativo por instâncias da nova versão do aplicativo em um conjunto fixo de máquinas virtuais (conjunto sem interrupção) em cada iteração.

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.

Propriedades

rollingjobs.deployment.strategy.rolling.
Estratégia de implantação sem interrupção.

estratégia: canário

A estratégia de implantação canário implementa alterações em um pequeno subconjunto de servidores.

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.

Propriedades

canaryjobs.deployment.strategy.canary.
Estratégia de implantação canário.

Comentários

A estratégia de implantação canário é avançada e ajuda a atenuar o risco envolvido na implantação de novas versões de aplicativos. Com essa estratégia, você pode implantar as alterações em um pequeno subconjunto de servidores primeiro. À medida que você tiver confiança na nova versão, poderá liberá-la para mais servidores na sua infraestrutura e rotear mais tráfego para ela.

Confira também