Share azure pipeline task 'env' across multiple tasks
Asked Answered
R

0

6

I have 2 pipelines that call code from the same repository. 1 pipeline calls console applications and the other pipeline calls automation tests.

Both tasks require the same env to be set. Right now my yamls look like this:

- task: DotNetCoreCLI@2
  displayName: Run Tests
  env:
    env.var.1: $(var1)
    env.var.2: $(var2)
  inputs:
    command: 'test'
    projects: '$(project)'
    publishTestResults: true
- task: CmdLine@2
  displayName: Run Console Application
  env:
    env.var.1: $(var1)
    env.var.2: $(var2)
  inputs:
    workingDirectory: '$(workingDir)'
    script: './$(appToRun)'
    failOnStderr: true

Is there any way I can use a variable to store all environment variables or a task to set them before these run? My actual tasks have about 20 environment variables that need to be set.

Remember answered 7/10, 2021 at 18:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.