File-type variable has byte order mark when using Powershell
Summary
Custom environment variables lets the user define a file-type variable. The contents of the file are different on different runners. On a Linux runner with a docker executor, the file contents are exactly what I pasted in to the variable in the project. On a Windows runner with a shell executor with the shell set to powershell, the file contents are preceded with a 3 byte UTF-8 byte order mark. And the file has an extra windows line ending at the end.
The file-type variable I'm using holds an ssh key. I'm running into this problem because ssh doesn't like byte order marks on keyfiles.
Steps to reproduce
- Add a custom environment variable of type file.
- Paste contents of a file (like an ssh key).
- Run a job on a windows runner using powershell.
- Look at a hexdump of the temporary file that gets created. It will have the byte order mark at the beginning and a windows line ending at the end.
Actual behavior
file type variables with runners using powershell have extra bytes at the beginning and end of the file, as compared to the contents specified in the project settings.
Expected behavior
file type variables should have just the file contents specified in the project settings.
Environment description
Using standalone omnibus gitlab 12.2.0-ee (30032e00da9) and a custom runner installation using the shell executor with shell set to powershell
config.toml contents
concurrent = 5
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "LabView builder 3"
limit = 4
output_limit = 32768
url = ""
token = ""
executor = "shell"
builds_dir = "C:\\builds"
shell = "powershell"
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[[runners]]
name = "Labview Webgenerator 2"
limit = 1
output_limit = 32768
url = ""
token = ""
executor = "shell"
builds_dir = "C:\\builds"
shell = "powershell"
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[[runners]]
name = "Labview SOM deployer"
limit = 1
output_limit = 32768
url = ""
token = ""
executor = "shell"
builds_dir = "C:\\builds"
shell = "powershell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
Used GitLab Runner version
Version: 12.4.0 Git revision: 1564076b Git branch: 12-4-stable GO version: go1.10.8 Built: 2019-10-21T14:37:13+0000 OS/Arch: windows/amd64