Bitbucket 管道您的系统缺少依赖项:Xvfb
Bitbucket pipeline Your system is missing the dependency: Xvfb
我正在尝试将 cypress 添加到 bitbucket 管道,但它告诉我需要安装 Xvfb,但我不知道如何继续。这是我的 bitbucket.pipelines.yml
# Template NodeJS build
# This template allows you to validate your NodeJS code.
# The workflow allows running tests and code linting on the default branch.
image: node:14.15.4
pipelines:
default:
- step:
name: Build
script:
- npm install
- npm run lint
- npm run cypress:run
这是我的 package.json 脚本
"scripts": {
"cypress:open": "cypress open",
"cypress:run": "npx cypress run --record --key xxxxxxxxxxxx"
}
并且本地测试运行很好
但是在管道中我收到了这个错误:
+ npm run cypress:run
> wallet-frontend@0.1.0 cypress:run /opt/atlassian/pipelines/agent/build
> npx cypress run --record --key 70004462-62d4-42ce-b359-5bff73d8b001
It looks like this is your first time using Cypress: 6.5.0
[16:30:09] Verifying Cypress can run /root/.cache/Cypress/6.5.0/Cypress [started]
[16:30:09] Verifying Cypress can run /root/.cache/Cypress/6.5.0/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.13)
Cypress Version: 6.5.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wallet-frontend@0.1.0 cypress:run: `npx cypress run --record --key xxxxxxxxx`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wallet-frontend@0.1.0 cypress:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Xvfb 是用于类 UNIX 操作系统的内存显示服务器,在您的例子中 Linux (Debian - 9.13)。这是赛普拉斯假定预先安装的系统级依赖项。在 bitbucket env 的情况下,它未安装,因此出现此错误。这主要用于显示 (UI),以防头部浏览器 运行ning cypress。
这里有几个简单的解决方法:
手动安装依赖项:我不建议这样做,因为除非您彻底检查所有依赖项,否则您可能会错过更多的依赖项。
运行 无头浏览器::无头浏览器不使用 Xvfb,所以不会遇到这个确切的错误,但正如我所说在第 1 点中,可能还有其他问题。命令将变成cypress run --headless
使用 Cypress 提供的 Docker 图像(建议):我可以看到您正在为此构建使用 node:14.15.4
图像.取而代之的是,使用官方提供的 cypress base images for whatever node version you want to run (Look for different node version in tags). If you look into the Dockerfile,你会看到他们已经努力在 docker 中安装 运行 Cypress 所需的依赖项(你可以在那里看到 Xvfb) .
此外,当您遇到与 cypress 相关的问题时,请寻找已经打开的问题,它们有一个非常活跃且有用的问题部分。我在那里发现了同样的问题:https://github.com/cypress-io/cypress/issues/14457
Cypress 为 CI 提供依赖项。
Linux
- Ubuntu/Debian
apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
- CentOS
yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-devel GConf2 nss libXScrnSaver alsa-lib
参考:https://docs.cypress.io/guides/continuous-integration/introduction#Dependencies
我正在尝试将 cypress 添加到 bitbucket 管道,但它告诉我需要安装 Xvfb,但我不知道如何继续。这是我的 bitbucket.pipelines.yml
# Template NodeJS build
# This template allows you to validate your NodeJS code.
# The workflow allows running tests and code linting on the default branch.
image: node:14.15.4
pipelines:
default:
- step:
name: Build
script:
- npm install
- npm run lint
- npm run cypress:run
这是我的 package.json 脚本
"scripts": {
"cypress:open": "cypress open",
"cypress:run": "npx cypress run --record --key xxxxxxxxxxxx"
}
并且本地测试运行很好
但是在管道中我收到了这个错误:
+ npm run cypress:run
> wallet-frontend@0.1.0 cypress:run /opt/atlassian/pipelines/agent/build
> npx cypress run --record --key 70004462-62d4-42ce-b359-5bff73d8b001
It looks like this is your first time using Cypress: 6.5.0
[16:30:09] Verifying Cypress can run /root/.cache/Cypress/6.5.0/Cypress [started]
[16:30:09] Verifying Cypress can run /root/.cache/Cypress/6.5.0/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.13)
Cypress Version: 6.5.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wallet-frontend@0.1.0 cypress:run: `npx cypress run --record --key xxxxxxxxx`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wallet-frontend@0.1.0 cypress:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Xvfb 是用于类 UNIX 操作系统的内存显示服务器,在您的例子中 Linux (Debian - 9.13)。这是赛普拉斯假定预先安装的系统级依赖项。在 bitbucket env 的情况下,它未安装,因此出现此错误。这主要用于显示 (UI),以防头部浏览器 运行ning cypress。
这里有几个简单的解决方法:
手动安装依赖项:我不建议这样做,因为除非您彻底检查所有依赖项,否则您可能会错过更多的依赖项。
运行 无头浏览器::无头浏览器不使用 Xvfb,所以不会遇到这个确切的错误,但正如我所说在第 1 点中,可能还有其他问题。命令将变成
cypress run --headless
使用 Cypress 提供的 Docker 图像(建议):我可以看到您正在为此构建使用
node:14.15.4
图像.取而代之的是,使用官方提供的 cypress base images for whatever node version you want to run (Look for different node version in tags). If you look into the Dockerfile,你会看到他们已经努力在 docker 中安装 运行 Cypress 所需的依赖项(你可以在那里看到 Xvfb) .
此外,当您遇到与 cypress 相关的问题时,请寻找已经打开的问题,它们有一个非常活跃且有用的问题部分。我在那里发现了同样的问题:https://github.com/cypress-io/cypress/issues/14457
Cypress 为 CI 提供依赖项。
Linux
- Ubuntu/Debian
apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
- CentOS
yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-devel GConf2 nss libXScrnSaver alsa-lib
参考:https://docs.cypress.io/guides/continuous-integration/introduction#Dependencies