Skip to content

Latest commit

 

History

History
249 lines (208 loc) · 7.98 KB

jobs-deployment-environment.md

File metadata and controls

249 lines (208 loc) · 7.98 KB
title description ms.date monikerRange
jobs.deployment.environment definition
Target environment name and optionally a resource name to record the deployment history.
11/12/2024
>=azure-pipelines-2020

jobs.deployment.environment definition

:::moniker range=">=azure-pipelines-2020"

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

:::moniker-end

:::moniker range=">=azure-pipelines-2020"

Definitions that reference this definition: jobs.deployment

:::moniker-end

Implementations

:::moniker range=">=azure-pipelines-2020"

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

:::moniker-end

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

:::moniker range=">=azure-pipelines-2020"

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.

:::moniker-end

Examples

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

:::moniker range=">=azure-pipelines-2020"

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.

:::moniker-end

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