jobs.deployment.environment definition

The environment keyword specifies the environment or its resource that is targeted by a deployment job of the pipeline.

Definitions that reference this definition: jobs.deployment

Implementations

Implementation Description
environment: string Deployment job with environment name.
environment: name, resourceName, resourceId, resourceType, tags Full syntax for complete control.

Remarks

An environment also holds information about the deployment strategy for running the steps defined inside the job.

You can reduce the deployment target's scope to a particular resource within the environment as shown here:

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

To specify an environment by name without using any additional properties, use the following syntax.

environment: string # Deployment job with environment name.

environment string.

Deployment job with environment name.

Examples

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

environment: name, resourceName, resourceId, resourceType, tags

To configure environment properties in addition to the name, use the full syntax.

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.

Properties

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.

Examples

The full syntax is:

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

If you specify an environment or one of its resources but don't need to specify other properties, you can shorten the syntax to:

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

You can reduce the deployment target's scope to a particular resource within the environment as shown here:

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

See also