階段定義

階段是相關作業的集合。

stages: [ stage | template ] # Stages are a collection of related jobs.

參考此定義的定義: 管線

清單類型

類型 描述
stage.stage 階段是相關作業的集合。
stages.template 您可以在一個檔案中定義一組階段,並將其多次用於其他檔案。

備註

根據預設,階段會循序執行。 除非透過 屬性指定 dependsOn ,否則每個階段只會在上述階段完成之後開始。

使用 核准檢查 手動控制何時應該執行階段。 這些檢查通常用來控制生產環境部署。

檢查是 資源擁有者可用的機制。 可用來控制管線中的階段何時取用資源。 身為環境等資源的擁有者,您可以定義取用資源的階段可以啟動之前所需的檢查。

目前, 環境支援手動核准檢查。 如需詳細資訊,請參閱 核准

範例

此範例會依序執行三個階段。 中間階段會平行執行兩個作業。

stages:
- stage: Build
  jobs:
  - job: BuildJob
    steps:
    - script: echo Building!
- stage: Test
  jobs:
  - job: TestOnWindows
    steps:
    - script: echo Testing on Windows!
  - job: TestOnLinux
    steps:
    - script: echo Testing on Linux!
- stage: Deploy
  jobs:
  - job: Deploy
    steps:
    - script: echo Deploying the code!

此範例會平行執行兩個階段。 為了簡潔起見,會省略作業和步驟。

stages:
- stage: BuildWin
  displayName: Build for Windows
- stage: BuildMac
  displayName: Build for Mac
  dependsOn: [] # by specifying an empty array, this stage doesn't depend on the stage before it

另請參閱

深入瞭解 階段條件變數