'Download dotenv job artifact via GitLab API
I'm trying to download dotenv artifact called release.env from the latest job related to branch feature/tests-update but API returns 404 error.
API docs: https://docs.gitlab.com/14.8/ee/api/job_artifacts.html#download-a-single-artifact-file-by-job-id
Request example:
curl -v --get --header "PRIVATE-TOKEN: <TOKEN>" --data-urlencode "job=create-release" "https://<gitlab-host>/api/v4/projects/2/jobs/artifacts/feature%2Ftests-update/raw/release%2Eenv"
GitLab community 14.8.
Solution 1:[1]
Unfortunately, artifacts:reports:dotenv artifacts are not exposed by the API. Only files in the artifacts archive (e.g. in artifacts:paths:) can be retrieved from this endpoint.
You are, however, able to download the dotenv reports from the UI.
As far as I can tell, this seems to be an oversight in the jobs API.
You can see that the jobs API lists dotenv reports in its artifacts with a filename of .env.gz:
...
'artifacts': [{'file_type': 'trace',
'size': 9954,
'filename': 'job.log',
'file_format': None},
{'file_type': 'dotenv',
'size': 66,
'filename': '.env.gz',
'file_format': 'gzip'}],
...
However, even if you use the filename .env.gz, it seems you cannot download this file from the API.
As a workaround, you can add your release.env file to artifacts:paths: and retrieve it in the way you described.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sytech |
