I am using a self-hosted deploy agent on a windows VM. The service is running under a "normal" windows administrative user in order to be able to access some system-specific installations and batch files. Whenever I try to run one of those batch files, some environment variables are not taken over from the windows-user the agent is running on.
For instance the variable %HOMEPATH%
.
I was able to proof this behavior by running this simple step:
- task: CmdLine@2
displayName: 'test set'
inputs:
script: |
echo HOMEPATH
echo %HOMEPATH%
Resulting in
Starting: test set
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.212.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\azagent\A1\_work\_temp\3a5484d6-470e-45df-a3b8-0631f3fa373f.cmd""
HOMEPATH
ECHO is off.
Finishing: test set
The variable %HOMEPATH%
is crucial for some git commands since it defines the file path for .gitconfig
which contains the git user / email.
I tried to re-install the agent which was a success (variable was set properly). But it lasted only until the next reboot.
Is there any parameter/option I can set to forward these environment variables to the run of the pipeline?
I would expect the pipeline agent to "forward" all windows user-specific environment variables to the pipeline steps.
Edit: Added info about administrative rights of windows user.