Continuous integration gitlab Cypress生成诱惑报告
我的.gitlab-ci.yml文件如下:Continuous integration gitlab Cypress生成诱惑报告,continuous-integration,gitlab-ci,cypress,pipeline,allure,Continuous Integration,Gitlab Ci,Cypress,Pipeline,Allure,我的.gitlab-ci.yml文件如下: image: cypress/base:14.16.0 stages: - test test: stage: test script: - npm install - npm run scripts 脚本所在的位置-->cypress运行--spec cypress/integration/UI/myScript.feature 在scripts参数之后添加另一个命令以生成allure报告时,gitlab管道向我抛出了
image: cypress/base:14.16.0
stages:
- test
test:
stage: test
script:
- npm install
- npm run scripts
脚本所在的位置-->cypress运行--spec cypress/integration/UI/myScript.feature
在scripts参数之后添加另一个命令以生成allure报告时,gitlab管道向我抛出了一个错误,即JAVA主路径未设置为生成allure报告
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH
因此,我将脚本更新为如下内容:
image: cypress/base:14.16.0
stages:
- test
- allure
test:
stage: test
script:
- npm install
- npm run clean:allure
- npm run scripts
allure_report:
stage: allure
when: always
image: timbru31/java-node
dependencies:
- test
script:
- npm install
- npm run generate-allure-report
artifacts:
when: always
paths:
- cypress/reportsAllure/allure-report/
- cypress/reportsAllure/allure-results/
其中generate allure report为-->allure generate cypress/reportsAllure/allure results--clean-o cypress/reportsAllure/allure report
但这里会生成空报告。有人知道为了生成诱惑报告,我需要从第一个阶段传递到下一个阶段的工件吗?这对我来说是可行的,但我使用默认文件夹位置,因此您需要更改这些工件路径,并在适当的地方追加
-o文件夹/allure报告
stages:
- test
- allure
- deploy
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules
.download_history: &download_history
after_script:
- apt-get install -y unzip
- mkdir backup && cd backup || true
- "curl --location --output report.zip --request GET \"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/jobs/artifacts/master/download?job=pages\" --header \"Authorization: Bearer ${CI_DEPLOY_TOKEN}\" || true"
- (unzip report.zip) || true
- cd ../
- (cp -r backup/public/history/ allure-results/history/) || true
.test_template: &test_template
image:
name: cypress/included:7.5.0
entrypoint: [""]
stage: test
variables:
CY_RUN_ID: ${CI_JOB_ID}
script:
- export CYPRESS_VIDEO=false
- npm install
- ./node_modules/.bin/cypress run --headless --env allure=true
artifacts:
when: always
paths:
- allure-results/
smoke:
<<: *test_template
<<: *download_history
allure_report:
stage: allure
when: always
image:
name: ubuntu:latest
entrypoint: [""]
dependencies:
- smoke
variables:
DEBIAN_FRONTEND: noninteractive
TZ: Europe/London
before_script:
- apt-get update
- apt-get install -y default-jdk wget unzip
- mkdir /work/
- wget https://github.com/allure-framework/allure2/releases/download/2.13.8/allure-2.13.8.zip -P /work/
- unzip /work/allure-2.13.8.zip -d /work/
script:
- /work/allure-2.13.8/bin/allure generate allure-results --clean -o allure-report
artifacts:
when: always
paths:
- allure-report/
- allure-results/
only:
- master
pages:
stage: deploy
when: always
dependencies:
- allure_report
script:
- mv allure-report/ public/
artifacts:
paths:
- public
expire_in: 30 days
only:
- master
阶段:
-试验
-诱惑力
-部署
隐藏物:
键:${CI\u COMMIT\u REF\u SLUG}
路径:
-节点单元
.下载\u历史记录:&下载\u历史记录
在脚本之后:
-apt-get-install-y解压
-mkdir备份和cd备份| |正确
-“curl--location--output report.zip--request GET\”https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/jobs/artifacts/master/download?job=pages\“--header\”授权:承载${CI_DEPLOY_TOKEN}\“| | true”
-(unzip report.zip)| |正确
-cd/
-(cp-r备份/公共/历史/诱惑结果/历史/)|正确
.测试模板:&测试模板
图片:
名称:cypress/包括:7.5.0
入口点:[“”]
阶段:测试
变量:
CY_RUN_ID:${CI_JOB_ID}
脚本:
-导出CYPRESS_视频=false
-npm安装
-./node_modules/.bin/cypress run--headless--env allure=true
人工产品:
时间:总是
路径:
-诱人的结果/
烟雾:
错误是什么?我还建议将npm安装
作为一个步骤,将npm运行脚本
作为另一个步骤,在我看来,分离使它更容易理解。我得到一个错误,没有设置JAVAHOME。这意味着allure需要在运行它的映像中包含Java。那么,如何在.yml中使用2幅图像呢?我在这篇文章中看到了,它们有着稍微不同的方法来保存具有趋势的诱惑数据。。。您还可以将image:cypress/base:14.16.0
移动到test:
中,因为该阶段不需要任何java,诱惑结果的产生得益于您使用的npm包,但是allure\u报告:
需要安装了java+allure的图像(我看不到任何安装诱惑的尝试,所以很难理解您将如何打开诱惑结果>诱惑报告)。