jobs.deployment.environment 定義

environment關鍵字會指定管線部署作業的目標環境或其資源。

參考此定義的定義: jobs.deployment

實作

實作 描述
環境:字串 具有環境名稱的部署作業。
環境:name、resourceName、resourceId、resourceType、tags 完整控制項的完整語法。

備註

環境也會保存部署策略的相關資訊,以執行作業內定義的步驟。

您可以將部署目標的範圍縮減為環境中的特定資源,如下所示:

environment: 'smarthotel-dev.bookings'
strategy:
  runOnce:
    deploy:
      steps:
      - task: KubernetesManifest@0
        displayName: Deploy to Kubernetes cluster
        inputs:
          action: deploy
          namespace: $(k8sNamespace)
          manifests: $(System.ArtifactsDirectory)/manifests/*
          imagePullSecrets: $(imagePullSecret)
          containers: $(containerRegistry)/$(imageRepository):$(tag)
          # value for kubernetesServiceConnection input automatically passed down to task by environment.resource input

環境:字串

若要依名稱指定環境而不使用任何其他屬性,請使用下列語法。

environment: string # Deployment job with environment name.

environment 字串。

具有環境名稱的部署作業。

範例

environment: environmentName.resourceName
strategy:                 # deployment strategy
  runOnce:              # default strategy
    deploy:
      steps:
      - script: echo Hello world

環境:name、resourceName、resourceId、resourceType、tags

若要除了名稱之外設定環境屬性,請使用完整的語法。

environment:
  name: string # Name of environment.
  resourceName: string # Name of resource.
  resourceId: string # Id of resource.
  resourceType: string # Type of environment resource.
  tags: string # List of tag filters.

屬性

name 字串。
環境的名稱。

resourceName 字串。
資源的名稱。

resourceId 字串。
資源的識別碼。

resourceType 字串。
環境資源的類型。

tags 字串。
標籤篩選清單。

範例

完整語法為:

environment:            # create environment and/or record deployments
  name: string          # name of the environment to run this job on.
  resourceName: string  # name of the resource in the environment to record the deployments against
  resourceId: number    # resource identifier
  resourceType: string  # type of the resource you want to target. Supported types - virtualMachine, Kubernetes
  tags: string          # comma separated tag names to filter the resources in the environment
strategy:               # deployment strategy
  runOnce:              # default strategy
    deploy:
      steps:
      - script: echo Hello world

如果您指定環境或其其中一個資源,但不需要指定其他屬性,您可以縮短語法以:

environment: environmentName.resourceName
strategy:         # deployment strategy
  runOnce:        # default strategy
    deploy:
      steps:
      - script: echo Hello world

您可以將部署目標的範圍縮減為環境中的特定資源,如下所示:

environment: 'smarthotel-dev.bookings'
strategy:
  runOnce:
    deploy:
      steps:
      - task: KubernetesManifest@0
        displayName: Deploy to Kubernetes cluster
        inputs:
          action: deploy
          namespace: $(k8sNamespace)
          manifests: $(System.ArtifactsDirectory)/manifests/*
          imagePullSecrets: $(imagePullSecret)
          containers: $(containerRegistry)/$(imageRepository):$(tag)
          # value for kubernetesServiceConnection input automatically passed down to task by environment.resource input

另請參閱