gitlab Cypress 生成诱惑力报告

gitlab Cypress generate allure report

我的 .gitlab-ci.yml 文件如下:

image: cypress/base:14.16.0

stages:
  - test
test:
  stage: test
  script:
    - npm install
    - npm run scripts

脚本所在的位置 --> cypress run --spec cypress/integration/UI/myScript.feature

在脚本参数后添加另一个命令以生成魅力报告时,gitlab 管道向我抛出 JAVA 主路径未设置为生成魅力报告的错误。

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/

生成魅力报告所在的位置 --> allure generate cypress/reportsAllure/allure-results --clean -o cypress/reportsAllure/allure-report

但是这里生成了空报告。有谁知道我需要将哪些工件从第一阶段传递到下一阶段才能生成魅力报告?

这对我有用,但我使用的是默认文件夹位置,因此您需要更改与工件路径相同的位置,并在适当的地方附加 -o folder/allure-report

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