【问题标题】:gitlab Cypress generate allure reportgitlab Cypress 生成诱惑报告
【发布时间】:2021-05-31 16:26:14
【问题描述】:

我的 .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/

generate-allure-report 在哪里 --> allure generate cypress/reportsAllure/allure-results --clean -o cypress/reportsAllure/allure-report

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

【问题讨论】:

  • 错误是什么?我还建议将npm install 作为一个步骤,将npm run scripts 作为另一个步骤,在我看来,分离会让它更容易理解。
  • 我收到未设置 JAVAHOME 的错误。这意味着 allure 需要在运行它的映像中包含 Java。那么如何在 .yml 中使用 2 张图片呢?
  • 我在这篇文章中遇到过,他们在保留魅力数据和趋势方面的方法略有不同...medium.com/testvagrant/…
  • 你也可以移动 image: cypress/base:14.16.0test: 因为那个阶段不需要任何 java ,由于你使用的 npm 包,诱惑结果正在发生,但是 @987654331 @ 需要安装了 java + allure 的图像(我看不到任何安装 allure 的尝试,所以很难理解你将如何打开 allure-results > allure-report)。

标签: continuous-integration gitlab-ci cypress pipeline allure


【解决方案1】:

这对我有用,但我使用的是默认文件夹位置,因此您需要更改与工件路径相同的位置并在适当的地方附加 -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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-02
    相关资源
    最近更新 更多