steps.powershell 정의

이 단계에서는 powershell Windows PowerShell(Windows) 또는 pwsh (Linux 및 macOS)를 사용하여 스크립트를 실행합니다.

steps:
- powershell: string # Required as first property. Inline PowerShell script.
  errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.
  failOnStderr: string # Fail the task if output is sent to Stderr?
  ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?
  workingDirectory: string # Start the script with this working directory.
  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:
- powershell: string # Required as first property. Inline PowerShell script.
  errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.
  failOnStderr: string # Fail the task if output is sent to Stderr?
  ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?
  workingDirectory: string # Start the script with this working directory.
  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.
steps:
- powershell: string # Required as first property. Inline PowerShell script.
  errorActionPreference: string # Unless otherwise specified, the error action preference defaults to the value stop. See the following section for more information.
  failOnStderr: string # Fail the task if output is sent to Stderr?
  ignoreLASTEXITCODE: string # Check the final exit code of the script to determine whether the step succeeded?
  workingDirectory: string # Start the script with this working directory.
  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.
  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.

이 정의를 참조하는 정의: 단계

속성

powershell 문자열. 첫 번째 속성으로 필요합니다.
인라인 PowerShell 스크립트.

errorActionPreference 문자열.
달리 지정하지 않는 한 오류 작업 기본 설정은 기본적으로 값 중지로 설정됩니다. 자세한 내용은 다음 단원을 참조하세요.

failOnStderr 문자열.
출력이 Stderr로 전송되면 작업이 실패하나요?

ignoreLASTEXITCODE 문자열.
스크립트의 최종 종료 코드를 확인하여 단계가 성공했는지 확인하세요.

workingDirectory 문자열.
이 작업 디렉터리로 스크립트를 시작합니다.

condition 문자열.
이 조건 식을 평가하여 이 작업을 실행할지 여부를 결정합니다.

continueOnErrorboolean입니다.
실패하더라도 계속 실행하시겠습니까?

displayName 문자열.
사람이 읽을 수 있는 작업의 이름입니다.

target대상입니다.
이 작업을 실행할 환경입니다.

enabledboolean입니다.
작업이 실행되면 이 작업을 실행합니까?

env 문자열 사전입니다.
프로세스 환경에 매핑할 변수입니다.

name 문자열.
단계의 ID입니다. 허용되는 값: [-_A-Za-z0-9]*.

timeoutInMinutes 문자열.
서버가 종료하기 전에 이 작업이 완료되기를 기다리는 시간입니다.

참고

파이프라인은 작업 수준 시간 제한으로 구성할 수 있습니다. 단계가 완료되기 전에 작업 수준 제한 시간 간격이 경과하면 단계가 더 긴 timeoutInMinutes 간격으로 구성된 경우에도 실행 중인 작업(단계 포함)이 종료됩니다. 자세한 내용은 시간 제한을 참조하세요.

retryCountOnTaskFailure 문자열.
작업이 실패할 경우 다시 시도 횟수입니다.

설명

powershell 키워드(keyword) PowerShell 작업의 바로 가기입니다. 작업은 Windows PowerShell(Windows) 또는 pwsh (Linux 및 macOS)를 사용하여 스크립트를 실행합니다.

각 PowerShell 세션은 실행되는 작업 기간 동안만 지속됩니다. 부트스트랩된 작업에 의존하는 작업은 부트스트랩과 동일한 작업이어야 합니다.

조건시간 제한에 대해 자세히 알아봅니다.

오류 작업 기본 설정

달리 지정하지 않는 한 오류 작업 기본 설정은 기본적으로 값 stop이며 줄 $ErrorActionPreference = 'stop' 은 스크립트의 맨 위에 추가됩니다.

오류 작업 기본 설정이 중지되도록 설정되면 오류로 인해 PowerShell이 작업을 종료하고 0이 아닌 종료 코드를 반환합니다. 이 작업은 실패로도 표시됩니다.

errorActionPreference: stop | continue | silentlyContinue
steps:
- powershell: |
    Write-Error 'Uh oh, an error occurred'
    Write-Host 'Trying again...'
  displayName: Error action preference
  errorActionPreference: continue

마지막 종료 코드 무시

스크립트에서 반환된 마지막 종료 코드는 기본적으로 확인됩니다. 0이 아닌 코드는 단계 실패를 나타내며, 이 경우 시스템에서 스크립트를 다음과 함께 추가합니다.

if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) { exit $LASTEXITCODE }

이 동작을 원하지 않는 경우 를 지정합니다 ignoreLASTEXITCODE: true.

ignoreLASTEXITCODE: boolean
steps:
- powershell: git nosuchcommand
  displayName: Ignore last exit code
  ignoreLASTEXITCODE: true

조건시간 제한에 대해 자세히 알아봅니다.

steps:
- powershell: Write-Host Hello $(name)
  displayName: Say hello
  name: firstStep
  workingDirectory: $(build.sourcesDirectory)
  failOnStderr: true
  env:
    name: Microsoft

참고 항목