jobs.deployment.environment 定义

environment 关键字指定管道部署作业所面向 环境 或其资源。

引用此定义的定义:jobs.deployment

实现

执行 说明
环境:字符串 具有环境名称的部署作业。
环境:名称、resourceName、resourceId、resourceType、标记 完整控件的完整语法。

注解

环境还包含有关部署策略的信息,用于运行作业中定义的步骤。

可以将部署目标的范围减少到环境中的特定资源,如下所示:

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

若要按名称指定环境而不使用任何其他属性,请使用以下语法。

environment: string # Deployment job with environment name.

environment 字符串。

具有环境名称的部署作业。

例子

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

环境:名称、resourceName、resourceId、resourceType、标记

若要配置除名称之外的环境属性,请使用完整的语法。

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

另请参阅