I am trying to use GitLab artifact dotenv file
In my GitLab CI YAML file, I wrote this block of code:
stages:
- build
build:
image: maven:3.9.5-sapmachine-21
stage: build
script:
- mvn clean install spring-boot:run
artifacts:
reports:
dotenv: build.env
In the build log, I am seeing this:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39.144 s
[INFO] Finished at: 2023-10-25T12:07:22Z
[INFO] ------------------------------------------------------------------------
Uploading artifacts for successful job
Uploading artifacts...
build.env: found 1 matching files and directories
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/7/artifacts: 400 Bad Request (Invalid Format) id=7 responseStatus=400 Bad Request status=400 token=64_BFV8L
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/7/artifacts: 400 Bad Request (Invalid Format) id=7 responseStatus=400 Bad Request status=400 token=64_BFV8L
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/7/artifacts: 400 Bad Request (Invalid Format) id=7 responseStatus=400 Bad Request status=400 token=64_BFV8L
FATAL: invalid argument
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1
How to use dotenv file?
The contents of your build.env
file are not in the correct format. You need to ensure that the file is a properly formatted dotenv file that also adheres to the additional restrictions as specified in the dotenv report documentation. The documentation also contains examples of how to correctly use this feature.
If you need to use a dotenv file that's not conforming to this specification, you can always pass the file down to other jobs as a normal artifact file:
# ...
artifacts:
paths:
- build.env
Then jobs should receive this artifact and you can consume them using whatever tooling for dotenv files you want.