需要安装 Xvfb 才能运行 bitbucket 管道

时间:2021-01-07 22:06:41

标签: node.js automation bitbucket cypress bitbucket-pipelines

查看以前的票证,似乎必须从 NPM 库安装它,我不知道为什么要我安装它,因为我无法在管道下运行 Sudo。

这是我的输出:

> installation_cypress@1.0.0 cy:run /opt/atlassian/pipelines/agent/build
> cypress run
It looks like this is your first time using Cypress: 6.2.1
[21:42:54]  Verifying Cypress can run /root/.cache/Cypress/6.2.1/Cypress [started]
[21:42:54]  Verifying Cypress can run /root/.cache/Cypress/6.2.1/Cypress [failed]
Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux (Debian - 9.9)
Cypress Version: 6.2.1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! installation_cypress@1.0.0 cy:run: `cypress run`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the installation_cypress@1.0.0 cy:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-01-07T21_42_54_586Z-debug.log
2021-01-07T21:42:54.598292177Z stdout P 

我们应该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:0)

对此的最佳解决方案是对您的 YAML 文件使用不同的配置。

现在,我使用这个配置解决了这个问题:

package.json:


        "scripts": {
        
         "jira:chrome": "cypress run --group 1x-chrome --record --headless --browser chrome",
        
          "jira:firefox": "cypress run --group 1x-firefox --record --headless --browser firefox",
        
          "jira:electron": "cypress run --group 1x-electron --record  --headless --browser electron"
        }

bitbucket-pipelines.yaml:

    
    
    image: cypress/included:6.2.1
    options:
      max-time: 10
      
    # job definition cross-browser testing
    jira-chrome: &jira-chrome
      name: JIRA Chrome tests
      caches:
        - node
        - cypress
      script:
        - npx @bahmutov/print-env BITBUCKET
        - npm run jira:chrome -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]
      artifacts:
        # store any generates images and videos as artifacts
        - cypress/screenshots/**
        - cypress/videos/**
    
    
    jira-firefox: &jira-firefox
      name: JIRA Firefox tests
      caches:
        - node
        - cypress
      script:
        - npx @bahmutov/print-env BITBUCKET
        - npm run jira:firefox -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]
    
      artifacts:
        # store any generates images and videos as artifacts
        - cypress/screenshots/**
        - cypress/videos/**
    
    
    jira-electron: &jira-electron
      name: JIRA Electron tests
      caches:
        - node
        - cypress
      script:
        - npx @bahmutov/print-env BITBUCKET
        - npm run jira:electron -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]
    
      artifacts:
        # store any generates images and videos as artifacts
        - cypress/screenshots/**
        - cypress/videos/**
        
    pipelines:
      default:
      - step:
          name: Install dependencies
          caches:
            - npm
            - cypress
            - node
          script:
            - npm ci
            - npx @bahmutov/print-env BITBUCKET
      - parallel:
        # cross-browser testing
        - step:
            <<: *jira-chrome    
        - step:
            <<: *jira-firefox
        - step:
            <<: *jira-electron
    definitions:
      caches:
       npm: $HOME/.npm
       cypress: $HOME/.cache/Cypress

这将解决此问题。如果您有任何问题或疑虑,请告诉我,我将非常乐意为您提供帮助...!