Open
Description
New issue checklist
- I searched for existing GitHub issues
- I read pipeline troubleshooting guide
- I checked how to collect logs
Task name
CmdLine
Task version
2.250.1
Issue Description
According to the CmdLine@2 task definition it's possible to define env variables, but they don't make it into the script the task creates before executing it.
- Is this by design?
- What's the use for the env mapping if they are not passed to the script?
- task: CmdLine@2
inputs:
script: 'printenv; node index.js'
env:
TEST_VAR: 'test value'
I've tried everything and the only alternatives seem to be defining definition variables (scope creep), or inline them (looks like a hack)
variables:
THIS_WORKS: 'test value'
- task: CmdLine@2
inputs:
script: 'printenv; THIS_ALSO_WORKS='test value' node index.js'
env:
THIS_DOESNT_WORK: 'test value'
Environment type (Please select at least one enviroment where you face this issue)
- Self-Hosted
- Microsoft Hosted
- VMSS Pool
- Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
No response
Operation system
azurelinux 3.0
Relevant log output
2025-04-15T22:09:00.5918020Z Generating script.
2025-04-15T22:09:00.5922168Z ##[debug]which 'bash'
2025-04-15T22:09:00.5926517Z ##[debug]found: '/usr/bin/bash'
2025-04-15T22:09:00.5926893Z Script contents:
2025-04-15T22:09:00.5927084Z printenv; node index.js
2025-04-15T22:09:00.5928387Z ##[debug]Agent.Version=4.253.0
2025-04-15T22:09:00.5928757Z ##[debug]agent.tempDirectory=/__w/_temp
2025-04-15T22:09:00.5929079Z ##[debug]check path : /__w/_temp
2025-04-15T22:09:00.5930961Z ========================== Starting Command Output ===========================
2025-04-15T22:09:00.5932345Z ##[debug]which '/usr/bin/bash'
2025-04-15T22:09:00.5933241Z ##[debug]found: '/usr/bin/bash'
2025-04-15T22:09:00.5934115Z ##[debug]/usr/bin/bash arg: /__w/_temp/e354e633-8a48-4786-9727-756c51b878e0.sh
2025-04-15T22:09:00.5937643Z ##[debug]exec tool: /usr/bin/bash
2025-04-15T22:09:00.5937995Z ##[debug]arguments:
2025-04-15T22:09:00.5938342Z ##[debug] /__w/_temp/e354e633-8a48-4786-9727-756c51b878e0.sh
2025-04-15T22:09:00.5940351Z [command]/usr/bin/bash /__w/_temp/e354e633-8a48-4786-9727-756c51b878e0.sh
>> printenv runs
VARS ARE PRINTED HERE BUT THE ENV DEFINED IN THE TASK ARE NOT AMONGS THE PRINTED ONES
>> node index.js runs
IT DOESN'T FIND THE ENV VARS
Full task logs with system.debug enabled
See above
Repro steps
See description