我正在尝试通过管道生成测试报告。生成了 Html,我可以访问 Gitlab 页面。但是,如果触发了新管道(或者即使是作业),则会生成测试报告并且前一个给出 404 错误,则会出现问题。(网址不同)
即例如:example.gitlab.io/project/{CI_PIPELINE_ID}/ 或 {CI_JOB_ID}
用例是这并没有给我一个选项来比较测试报告。
一个解决方案是缓存公用文件夹,然后我可以在各自的 URL 中访问不同版本的测试。
但是我对此并不陌生,我不确定这是否正确,因为我必须手动清除缓存,我认为这仅适用于项目的维护者和所有者。
有没有其他方法可以保留以前管道中的 Gitlab 页面?
PS:我是新手
编辑:添加示例 gitlab-ci.yml 文件以供参考:
stages:
- build
pages:
image: cypress/base:10
stage: build
script:
- npm ci
- npx cypress run
after_script:
# Generate report using mochaswesome-merge
# Combine different json files into single json file
- npx mochawesome-merge cypress/reporters/json/*.json > cypress/reporters/output.json
# Generate html from the json file using marge. Eache new html is created inside a new folder based on timeline.
- npx marge cypress/reporters/output.json -f cypress/reporters/$(date +"%Y%m%d-%Ih%Mm") -o ./ --inline
# Make a public folder for the gitlab page to be created
- mkdir -p public
- mkdir -p public/$(date +"%Y%m%d-%Ih%Mm")/
# Moving the contents of the report folder inside a public under the same folder name as the report
- mv cypress/reporters/* public/$(date +"%Y%m%d-%Ih%Mm")/
#Creating an index html that will have the file listing of all the generated reports
- cd public
- echo "<html><body><h1>File listing:</h1>" > ./index.html
- find -iname '*.html' -execdir echo "<a href='{}'>{}</a><br><br/>" \; >> ./index.html
- echo "</body></html>" >> ./index.html
when: always
only:
- dev
#Cache is required so that we have the report folder created from each pipeline. This allows us to list the files in the index html.
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- public
#Artifact of each pipeline. Contains report of that particular pipeline.
artifacts:
name: "$CI_JOB_ID"
expire_in: 1 day
when: always
paths:
- public