Share via


jobs.deployment.strategy.runOnce 정의

runOnce 배포 전략은 각 단계를 한 번 실행하여 변경 내용을 롤아웃합니다.

runOnce:
  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.

이 정의를 참조하는 정의: jobs.deployment.strategy

속성

preDeploypreDeployHook.
runOnce 배포 전략에 대한 후크를 미리 배포합니다.

deploydeployHook.
runOnce 배포 전략에 대한 후크를 배포합니다.

routeTrafficrouteTrafficHook.
runOnce 배포 전략에 대한 트래픽 후크를 라우팅합니다.

postRouteTrafficpostRouteTrafficHook.
runOnce 배포 전략에 대한 사후 경로 트래픽 후크입니다.

ononSuccessOrFailureHook.
runOnce 배포 전략에 대한 성공 또는 실패 후크.

설명

runOnce 는 모든 수명 주기 후크( 즉 preDeploydeploy, , routeTrafficpostRouteTraffic)가 한 번 실행되는 가장 간단한 배포 전략입니다. 그런 다음, on:success 또는 on:failure가 실행됩니다.

수명 주기 후크에 대한 설명

preDeploy: 애플리케이션 배포가 시작되기 전에 리소스를 초기화하는 단계를 실행하는 데 사용됩니다.

deploy: 애플리케이션을 배포하는 단계를 실행하는 데 사용됩니다. 아티팩트 다운로드 작업은 배포 작업에 대한 후크에 deploy 만 자동으로 삽입됩니다. 아티팩트 다운로드를 중지하려면 파이프라인 아티팩트 다운로드 작업을 지정하여 다운로드할 특정 아티팩트 를 사용 - download: none 하거나 선택합니다.

routeTraffic: 업데이트된 버전으로 트래픽을 제공하는 단계를 실행하는 데 사용됩니다.

postRouteTraffic: 트래픽이 라우팅된 후 단계를 실행하는 데 사용됩니다. 일반적으로 이러한 작업은 정의된 간격 동안 업데이트된 버전의 상태를 모니터링합니다.

on: failure또는 on: success: 롤백 작업 또는 클린 단계를 실행하는 데 사용됩니다.

예제

다음 예제 YAML 코드 조각은 배포 전략을 사용하여 배포 작업을 간단하게 사용하는 방법을 runOnce 보여 줍니다. 이 예제에는 체크 아웃 단계가 포함되어 있습니다.


jobs:
  # Track deployments on the environment.
- deployment: DeployWeb
  displayName: deploy Web App
  pool:
    vmImage: ubuntu-latest
  # Creates an environment if it doesn't exist.
  environment: 'smarthotel-dev'
  strategy:
    runOnce:
      deploy:
        steps:
        - checkout: self 
        - script: echo my first deployment

이 작업을 실행할 때마다 환경에 대해 smarthotel-dev 배포 기록이 기록됩니다.

참고

  • 또한 이전 예제와 같이 빈 리소스가 있는 환경을 만들고 이를 추상 셸로 사용하여 배포 기록을 기록할 수도 있습니다.

다음 예제에서는 파이프라인이 배포 작업의 대상으로 사용할 환경과 리소스를 모두 참조하는 방법을 보여 줍니다.

jobs:
- deployment: DeployWeb
  displayName: deploy Web App
  pool:
    vmImage: ubuntu-latest
  # Records deployment against bookings resource - Kubernetes namespace.
  environment: 'smarthotel-dev.bookings'
  strategy: 
    runOnce:
      deploy:
        steps:
          # No need to explicitly pass the connection details.
        - task: KubernetesManifest@0
          displayName: Deploy to Kubernetes cluster
          inputs:
            action: deploy
            namespace: $(k8sNamespace)
            manifests: |
              $(System.ArtifactsDirectory)/manifests/*
            imagePullSecrets: |
              $(imagePullSecret)
            containers: |
              $(containerRegistry)/$(imageRepository):$(tag)

이 방법은 다음과 같은 이점이 있습니다.

  • 환경 내의 모든 리소스에 대한 기록을 기록하는 것이 아니라 환경 내의 특정 리소스에 대한 배포 기록을 기록합니다.
  • 배포 작업의 단계는 배포 작업이 환경에 연결되므로 리소스의 연결 세부 정보(이 경우 Kubernetes 네임스페이스smarthotel-dev.bookings)를 자동으로 상속합니다. 이는 작업의 여러 단계에 대해 동일한 연결 세부 정보가 설정된 경우에 유용합니다.

추가 정보