I'm trying to figure out how to pass in environment variables in a similar fashion to the official pwsh/bash tasks available in Azure DevOps. For example:
- pwsh: Write-Host $env:SOMEVAR
env:
SOMEVAR: example
I was looking at the task.json
of the official tasks and they don't explicitly have an input for the environment variable mapping, there's simply "showEnvironmentVariables": true
, which is what this repo appears to use as well.
I tried to do this with the authenticated scripts task and got the "mapping was not expected error" where I tried to define the env
mapping.
- task: AuthenticatedPowerShell@1
inputs:
serviceConnection: generic-service-connection
targetType: inline
script: |
Write-Host $env:SOMEVAR
env:
SOMEVAR: example
My use case here is that I'm trying to use the AuthenticatedPowerShell
task in a YAML template that would be consumed by many pipelines, but I'd like to have a parameter available in the template that would allow pipelines to pass in custom environment variables for the script on an as-needed basis. I might be able to parse the parameter and set environment vars within the pwsh script it self, but though this would be cleaner and easier.
I'd be happy to make a PR but I can't quite figure out what is needed. Any thoughts? Love the extension otherwise, thanks for putting it together ❤️