Hello
Problem to solve
I’d like to add some links to the merge request ui and it looks like GitLab CI/CD artifacts reports types | GitLab Docs can help doing this but unfortunately, that does not seem to work. The upload of the annotation json file fails. Thanks for your help.
Steps to reproduce
Here’s what the job looks like:
buildStaging:
stage: test
environment: staging
script:
- yarn build
- yarn analyze --html bundle-analysis/index.html
artifacts:
paths:
- build/
- bundle-analysis/index.html
- annotation.json
reports:
annotations: annotation.json
pages:
publish: bundle-analysis
path_prefix: "$CI_MERGE_REQUEST_IID-bundle-analysis/"
expire_in: 2 weeks
(To easily test, annotation.json is for now in the repository, once this works I’ll generate it)
Here is the content of annotation.json:
{
"bundle_analysis": [
{ "external_link": "https://example.com", "label": "Bundle analysis" }
]
}
I also tried with something like (suggested by Mistral AI)
[
{
"description": "Message affiché dans la MR",
"external_link": "https://lien-externe.com"
}
]
in both case, the job ends with something like:
Uploading artifacts as "archive" to coordinator... 201 Created id=13203047111 responseStatus=201 Created token=glcbt-6c
Uploading artifacts...
annotation.json: found 1 matching artifact files and directories
WARNING: Uploading artifacts as "annotations" to coordinator... POST https://gitlab.com/api/v4/jobs/13203047111/artifacts: 400 Bad Request (Annotations files must be a JSON object) id=13203047111 responseStatus=400 Bad Request status=400 token=glcbt-6c
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "annotations" to coordinator... POST https://gitlab.com/api/v4/jobs/13203047111/artifacts: 400 Bad Request (Annotations files must be a JSON object) id=13203047111 responseStatus=400 Bad Request status=400 token=glcbt-6c
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "annotations" to coordinator... POST https://gitlab.com/api/v4/jobs/13203047111/artifacts: 400 Bad Request (Annotations files must be a JSON object) id=13203047111 responseStatus=400 Bad Request status=400 token=glcbt-6c
FATAL: invalid argument
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1
Versions
-
GitLab.comSaaS
Gitlab runner: Running with gitlab-runner 17.1.0 (fe451d5a)