Pass environmental variables to .yml?

Ingo Speckens 1 Reputation point
2021-06-21T09:10:38.287+00:00

Hi community, I tried to add the .env variables but it isn't working. Do I need to pass the variables in the .yml as well? Please help, .yml below.

107544-image.png

# .yml  
# Docker  
# Build and push an image to Azure Container Registry  
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker  
  
trigger:  
- main  
  
resources:  
- repo: self  
  
variables:  
  # Container registry service connection established during pipeline creation  
  dockerRegistryServiceConnection: xxx  
  imageRepository: xxx  
  containerRegistry: xxx  
  dockerfilePath: '$(Build.SourcesDirectory)/client/Dockerfile'  
  tag: '$(Build.BuildId)'  
  
  # Agent VM image name  
  vmImageName: 'ubuntu-latest'  
  
stages:  
- stage: Build  
  displayName: Build and push stage  
  jobs:  
  - job: Build  
    displayName: Build  
    pool:  
      vmImage: $(vmImageName)  
    steps:  
    - task: Docker@2  
      displayName: Build and push an image to container registry  
      inputs:  
        command: buildAndPush  
        repository: $(imageRepository)  
        dockerfile: $(dockerfilePath)  
        containerRegistry: $(dockerRegistryServiceConnection)  
        tags: |  
          $(Build.BuildNumber)  
          latest  
  
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,972 questions
{count} votes

1 answer

Sort by: Most helpful
  1. sadomovalex 3,636 Reputation points
    2021-06-21T15:07:08.477+00:00

    in order to use variables in yml you need to add them to your pipeline > variables:
    107609-2021-06-21-18-04-51.png

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.