steps.powershell-definíció

A powershell lépés egy szkriptet futtat a Windows PowerShell (Windows rendszeren) vagy pwsh (Linux és macOS) használatával.

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.

A definícióra hivatkozó definíciók: lépések

Tulajdonságok

powershell Karakterlánc. Első tulajdonságként kötelező megadni.
Beágyazott PowerShell-szkript.

errorActionPreference Karakterlánc.
Ha másként nincs megadva, a hibaművelet beállításai alapértelmezés szerint az értékmegállításra lesznek beszüntetve. További információért tekintse meg az alábbi szakaszt.

failOnStderr Karakterlánc.
Sikertelen a feladat, ha a kimenetet a Stderrnek küldi?

ignoreLASTEXITCODE Karakterlánc.
Ellenőrizze a szkript végleges kilépési kódját annak megállapításához, hogy a lépés sikeres volt-e?

workingDirectory Karakterlánc.
Indítsa el a szkriptet ezzel a munkakönyvtárral.

condition Karakterlánc.
Értékelje ki ezt a feltételkifejezést, és állapítsa meg, hogy futtatni kívánja-e ezt a feladatot.

continueOnErrorlogikai érték.
Továbbra is fut a hiba esetén is?

displayName Karakterlánc.
A feladat emberi olvasásra alkalmas neve.

targetcél.
Környezet, amelyben futtatni szeretné ezt a feladatot.

enabledlogikai érték.
Futtassa ezt a feladatot a feladat futtatásakor?

env sztringszótár.
Változók a folyamat környezetébe való leképezéshez.

name Karakterlánc.
A lépés azonosítója. Elfogadható értékek: [-_A-Za-z0-9]*.

timeoutInMinutes Karakterlánc.
Ideje megvárni, amíg a feladat befejeződik, mielőtt a kiszolgáló leáll.

Megjegyzés

Előfordulhat, hogy a folyamatok feladatszintű időtúllépéssel konfigurálhatók. Ha a feladatszint időtúllépési időköze a lépés befejezése előtt eltelik, a futó feladat (beleértve a lépést is) leáll, még akkor is, ha a lépés hosszabb timeoutInMinutes időközzel van konfigurálva. További információ: Időtúllépések.

retryCountOnTaskFailure Karakterlánc.
Újrapróbálkozások száma, ha a feladat meghiúsul.

Megjegyzések

A powershell kulcsszó a PowerShell-feladat parancsikonja. A feladat egy szkriptet futtat Windows PowerShell (Windows rendszeren) vagy (Linux és pwsh macOS) használatával.

Minden PowerShell-munkamenet csak annak a feladatnak az időtartamára tart, amelyben fut. A rendszerindítótól függő feladatoknak ugyanabban a feladatban kell lenniük, mint a bootstrapnak.

További információ a feltételekről és az időtúllépésekről.

Hibaművelet beállításai

Ha másként nincs megadva, a hibaművelet beállításai alapértelmezés szerint a értékre stopkerülnek, és a sor $ErrorActionPreference = 'stop' a szkript elejére van előre felfűzve.

Ha a hibaművelet beállítása leállításra van állítva, a hibák miatt a PowerShell leállítja a feladatot, és nem aero kilépési kódot ad vissza. A feladat is Sikertelenként van megjelölve.

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

Utolsó kilépési kód figyelmen kívül hagyása

A szkriptből visszaadott utolsó kilépési kód alapértelmezés szerint be van jelölve. A nonzero kód lépéshibát jelez, amely esetben a rendszer hozzáfűzi a szkriptet a következőhöz:

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

Ha nem szeretné ezt a viselkedést, adja meg a értéket ignoreLASTEXITCODE: true.

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

További információ a feltételekről és az időtúllépésekről.

Példák

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

Lásd még