代码之家  ›  专栏  ›  技术社区  ›  Vladeezy

如果其中一个脚本失败,如何继续运行脚本?GITLAB CI

  •  0
  • Vladeezy  · 技术社区  · 4 年前

    这是我的yml文件:

    stages:
      - testing
      - deploy 
    
    docker_job:
      stage: testing
      tags:
        - docker
      image: atools/chrome-headless:java11-node14-latest 
      
      before_script:
        - npm ci 
        - npx playwright install 
        - npm install allure-commandline --save-dev
      
      script:
        - npm run BookingTestDEV --project=BookingTesting
        - npx playwright test --project=BookEngineTests
        - npm run BookingTestNEO --project=BookingTesting
    
    
      after_script:
        - npx allure generate allure-results --clean 
      rules:
          - when: always
      allow_failure: true
      artifacts: 
        when: always
        paths:
          - ./allure-report
        expire_in: 7 day 
    
    pages: 
      stage: deploy
      script:
        - mkdir public 
        - mv ./allure-report/* public
      artifacts:
        paths:
          - public
      rules:
        - when: always
        
    
    

    如果第一个脚本 -npm run BookingTestDEV--project=BookingTesting失败,其他测试将被跳过,如何运行它们?在github上是否有if():always like的模拟?

    1 回复  |  直到 4 年前
        1
  •  1
  •   seldesjo    4 年前

    在大多数情况下,如果其中一个命令抛出的退出代码不是0,则管道应该失败。但是,在某些情况下,其余命令仍应运行。一个可能的解决办法是增加 || true 在命令的末尾。

    例如:

     script:
        - npm run BookingTestDEV --project=BookingTesting || true
        - npx playwright test --project=BookEngineTests
        - npm run BookingTestNEO --project=BookingTesting