Uploading build.env fails

I’m using a Windows powershell runner (on a self-hosted gitlab 13.2.6-ee), and I have a script step in a stage that writes to ‘build.env’. I then try to upload that as an artifact report:

artifacts:
reports:
dotenv: build.env

But the build keeps failing:

Uploading artifacts…

44Runtime platform arch=amd64 os=windows pid=7864 revision=738bbe5a version=13.3.1

45build.env: found 1 matching files and directories

46WARNING: Failed to load system CertPool: crypto/x509: system root pool is not available on Windows

47WARNING: Uploading artifacts as “dotenv” to coordinator… failed id=19556 responseStatus=500 Internal Server Error status=500 token=8TuGoYfQ

48WARNING: Retrying… context=artifacts-uploader error=invalid argument

49WARNING: Uploading artifacts as “dotenv” to coordinator… failed id=19556 responseStatus=500 Internal Server Error status=500 token=8TuGoYfQ

50WARNING: Retrying… context=artifacts-uploader error=invalid argument

51WARNING: Uploading artifacts as “dotenv” to coordinator… failed id=19556 responseStatus=500 Internal Server Error status=500 token=8TuGoYfQ

52FATAL: invalid argument

54ERROR: Job failed: exit status 1

I’ve searched long for a solution to this issue and I found it in a related Gitlab Issue. https://gitlab.com/gitlab-org/gitlab/-/issues/212629#note_430278657

Not sure if this is the case for you, but when creating the build.env file you need to use Add-Content -Path build.env -Value "Value=123" and not any kind of piping to Out-File or using echo, as those seem to create UCS-2 LE BOM files and dotenv can’t handle those for some reason

4 Likes