步驟定義

步驟是構成作業的線性作業序列。

steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # Steps are a linear sequence of operations that make up a job.
steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | publish | template ] # Steps are a linear sequence of operations that make up a job.

參考此定義的定義: pipelinejobs.job

清單類型

類型 描述
steps.task 執行工作。
steps.script 在其他平臺上,使用 Windows 和 Bash 上的cmd.exe來執行腳本。
steps.powershell 在 Windows) 上使用 Windows PowerShell (或 pwsh (Linux 和 macOS) 來執行腳本。
steps.pwsh 在 Windows、macOS 和 Linux 上的 PowerShell Core 中執行腳本。
steps.bash 在 Windows、macOS 和 Linux 上的 Bash 中執行腳本。
steps.checkout 設定管線簽出原始程式碼的方式。
steps.download 從另一個與管線資源相關聯的 Azure Pipeline 下載與目前執行相關聯的成品,或從另一個與管線資源相關聯的成品。
steps.downloadBuild 下載組建成品。
steps.getPackage 從 Azure Artifacts 中的套件管理摘要或Azure DevOps Server下載套件。
steps.publish 發佈 (將檔案或資料夾上傳) 為其他作業和管線可以使用的管線成品。
steps.template 在一個檔案中定義一組步驟,並在另一個檔案中多次使用它。
steps.reviewApp 下載會在部署階段提供者下動態建立資源。
類型 描述
steps.task 執行工作。
steps.script 在其他平臺上,使用 Windows 和 Bash 上的cmd.exe來執行腳本。
steps.powershell 在 Windows) 上使用 Windows PowerShell (或 pwsh (Linux 和 macOS) 來執行腳本。
steps.pwsh 在 Windows、macOS 和 Linux 上的 PowerShell Core 中執行腳本。
steps.bash 在 Windows、macOS 和 Linux 上的 Bash 中執行腳本。
steps.checkout 設定管線簽出原始程式碼的方式。
steps.download 從另一個與管線資源相關聯的 Azure Pipeline 下載與目前執行相關聯的成品,或從另一個與管線資源相關聯的成品。
steps.downloadBuild 下載組建成品。
steps.publish 發佈 (將檔案或資料夾上傳) 為其他作業和管線可以使用的管線成品。
steps.template 在一個檔案中定義一組步驟,並在另一個檔案中多次使用它。

備註

每個步驟都會在代理程式上自行執行,並可存取本機硬碟上的管線工作區。 此行為表示不會在步驟之間保留環境變數,但檔案系統變更是 。

除了工作或步驟特定屬性之外,所有工作和步驟都支援一組通用屬性,例如 enabledenv 。 如需設定這些屬性的詳細資訊,請參閱 工作控制選項工作環境變數

範例

steps:
- script: echo This runs in the default shell on any machine
- bash: |
    echo This multiline script always runs in Bash.
    echo Even on Windows machines!
- pwsh: |
    Write-Host "This multiline script always runs in PowerShell Core."
    Write-Host "Even on non-Windows machines!"

另請參閱