jobs.deployment.environment definition

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 字符串。
资源的 ID。

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

请参阅