jobs.deployment.environment 定義

environment キーワードは、パイプラインの配置ジョブの対象となる環境またはそのリソースを指定します。

この定義を参照する定義: jobs.deployment

実装

実装 説明
environment: string 環境名を持つデプロイ ジョブ。
environment: 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

追加のプロパティを使用せずに名前で環境を指定するには、次の構文を使用します。

environment: string # Deployment job with environment name.

environment 文字列。

環境名を持つデプロイ ジョブ。

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

environment: 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

環境またはそのリソースの 1 つだけを指定し、他のプロパティの指定は必要ない場合は、構文を次のように短縮できます。

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

関連項目