script 步驟會使用 Windows 上的 cmd.exe,在其他平台上執行 Bash 腳本。
steps:
- script: string # Required as first property. An inline script.
failOnStderr: string # Fail the task if output is sent to Stderr?
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.
參考此定義的定義:步驟
屬性
script 字串。 做為第一個屬性的必要屬性。
內嵌腳本。
failOnStderr 字串。
如果輸出傳送至 Stderr,工作失敗?
workingDirectory 字串。
使用此工作目錄啟動腳本。 如果你沒有指定值,步驟會從 $(Build.SourcesDirectory)開始。
condition 字串。
評估此條件表示式,以判斷是否要執行這項工作。
continueOnError
布林值。
即使在失敗時仍繼續執行?
displayName 字串。
工作的人類可讀取名稱。
target
目標。
要在其中執行這項工作的環境。
enabled
布林值。
作業執行時執行這項工作?
env 字串字典。
變數,以對應至進程的環境。
name 字串。
步驟的標識碼。 可接受的值:[-_A-Za-z0-9]*。
timeoutInMinutes 字串。
等候此工作在伺服器終止之前完成的時間。
備註
管線可能會設定作業層級逾時。 如果作業層級逾時間隔在步驟完成之前經過,即使步驟設定較長的 timeoutInMinutes 間隔,仍會終止執行中的作業(包括您的步驟)。 如需詳細資訊,請參閱 逾時。
retryCountOnTaskFailure 字串。
如果工作失敗,重試次數。
備註
script 關鍵詞是命令行工作 的快捷方式。
工作會使用 Windows 上的 cmd.exe,在其他平臺上使用 Bash 來執行腳本。
如果你沒有設定 workingDirectory,腳本會從 $(Build.SourcesDirectory)執行,這是該工作已借出倉庫的根節點。 當你的腳本需要在不同的資料夾開始時,例如包含建置腳本或專案檔案的子目錄,就會設定 workingDirectory 。
範例
如果您未指定命令模式,您可以將 target 結構縮短為:
- script:
target: string # container name or the word 'host'
steps:
- script: echo Hello world!
displayName: Say hello
以下範例顯示未指定時 workingDirectory 的預設工作目錄:
steps:
- script: |
echo "Default working directory:"
pwd
displayName: Show default working directory