Gitlab-CI
here is an exmaple to describe my probelm. config.toml:
[[runners]]
name = ...
url = ...
...
executor = shell
shell = "powershell"
....
.gitlab-ci.yml :
test-job:
tags:
- test-runner
script:
- echo $env:windir
- echo $env:OneDrive
output:
Running with gitlab-runner 15.2.1
...
...
Executing "step_script" stage of the job script
...
...
...
$ echo $env:windir
C:\Windows
$ echo $env:OneDrive
Job succeeded
Issue
As you can see, there is no output of "echo $env:OneDrive" because $env:OneDrive is an user variable. But i can get the output of "echo $env:windir" because $env:windir is a system variable.
CodePudding user response:
there is no output of "echo $env:OneDrive" because $env:OneDrive is an user variable. But i can get the output of "echo $env:windir" because $env:windir is a system variable.
Seems like you kind of answered your own question here. That is the expected (system-defined) behavior for GitLab powershell runners -- All powershell commands are executed with the -NoProfile
option, meaning profiles are not used and user environment variables will not be loaded.
There is a feature request to be able to configure this behavior, but at the time of writing, this capability is not available. Therefore, you must set any such environment variables another way (say, as system variables, in the runner settings, instance settings, or group/project CICD settings).