Share via


steps.powershell tanımı

Adım, powershell Windows PowerShell (Windows üzerinde) veya pwsh (Linux ve macOS) kullanarak bir betik çalıştırır.

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.

Bu tanıma başvuran tanımlar: adımlar

Özellikler

powershell Dize. İlk özellik olarak gereklidir.
Satır içi PowerShell betiği.

errorActionPreference Dize.
Aksi belirtilmediği sürece hata eylemi tercihi varsayılan olarak değer durdurma olarak belirlenir. Daha fazla bilgi için aşağıdaki bölüme bakın.

failOnStderr Dize.
Çıktı Stderr'a gönderilirse görev başarısız mı olur?

ignoreLASTEXITCODE Dize.
Adımın başarılı olup olmadığını belirlemek için betiğin son çıkış kodu denetlensin mi?

workingDirectory Dize.
Betiği bu çalışma diziniyle başlatın.

condition Dize.
Bu görevin çalıştırılıp çalıştırılmayacağını belirlemek için bu koşul ifadesini değerlendirin.

continueOnErrorboole değeri.
Hata durumunda bile çalışmaya devam mı edin?

displayName Dize.
Görevin insan tarafından okunabilen adı.

targethedef.
Bu görevin çalıştırıldığı ortam.

enabledboole değeri.
İş çalıştırıldığında bu görev çalıştırılacak mı?

env dize sözlüğü.
İşlemin ortamına eşlenen değişkenler.

name Dize.
Adımın kimliği. Kabul edilebilir değerler: [-_A-Za-z0-9]*.

timeoutInMinutes Dize.
Sunucu sonlandırmadan önce bu görevin tamamlanmasını bekleme süresi.

Not

İşlem hatları iş düzeyi zaman aşımı ile yapılandırılabilir. İş düzeyi zaman aşımı aralığı adımınız tamamlanmadan önce geçerse, adım daha uzun timeoutInMinutes bir aralıkla yapılandırılmış olsa bile çalışan iş (adımınız dahil) sonlandırılır. Daha fazla bilgi için bkz . Zaman Aşımları.

retryCountOnTaskFailure Dize.
Görev başarısız olursa yeniden deneme sayısı.

Açıklamalar

powershell anahtar sözcüğü, PowerShell görevi için bir kısayoldur. Görev, Windows PowerShell (Windows üzerinde) veya pwsh (Linux ve macOS) kullanarak bir betik çalıştırır.

Her PowerShell oturumu yalnızca çalıştığı işin süresi boyunca sürer. Önyüklemenin ne olduğuna bağlı görevlerin bootstrap ile aynı işte olması gerekir.

Koşullar ve zaman aşımları hakkında daha fazla bilgi edinin.

Hata eylemi tercihi

Aksi belirtilmedikçe, hata eylemi tercihi varsayılan olarak değerine stopayarlanır ve satır $ErrorActionPreference = 'stop' betiğinizin en üstüne eklenir.

Hata eylemi tercihi durdurulacak şekilde ayarlandığında, hatalar PowerShell'in görevi sonlandırmasına ve sıfır olmayan bir çıkış kodu döndürmesine neden olur. Görev ayrıca Başarısız olarak işaretlenir.

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

Son çıkış kodunu yoksay

Betiğinizden döndürülen son çıkış kodu varsayılan olarak denetlenür. Sıfır olmayan kod bir adım hatasını gösterir; bu durumda sistem betiğinizi şu şekilde ekler:

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

Bu davranışı istemiyorsanız belirtin ignoreLASTEXITCODE: true.

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

Koşullar ve zaman aşımları hakkında daha fazla bilgi edinin.

Örnekler

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

Ayrıca bkz.