要运行赛普拉斯,需要安装系统依赖项,Cypress Dependencies
apt-get install libgtk2.0-0 libgtk-3-0 libnotify-dev
libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
要在本地Jenkins中运行Cypress脚本,我正在创建 Jenkinsfile
。
Jenkinsfile在Jenkins中具有阶段命令npx cypress run
,并且失败"Your system is missing the dependency: Xvfb"
。
首先想到的是安装npm package xvfb,但这并不能解决问题。
然后,我通过本地的Jenkins Jenkins plugin Xvfb安装了,并且成功了!
我的目标是在远程Jenkins上运行Cypress,并且失败的方式与"Your system is missing the dependency: Xvfb"
相同。
重要说明::我无权访问远程Jenkins服务和命令 Manage Plugins 来请求安装Jenkins plugin Xvfb。
由于尚不清楚如何通过Jenkinsfile
安装Jenkins plugin Xvfb,因此我尝试在Jenkinsfile
中进行shell脚本编写。除xvfb
之外,每个系统软件包似乎都已安装,因此这种安装到远程Jenkins服务的方法不起作用。
sh 'sudo apt-get install libgtk2.0-0 libgtk-3-0
libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
libxtst6 xauth xvfb -y'
在运行npm安装之前,是否有人知道编写脚本Jenkinsfile
来安装Jenkins plugin Xvfb?
谢谢,非常感谢您的协助
答案 0 :(得分:0)
我通过创建一个 docker 文件解决了这个问题,Jenkinsfile 在其中使用了它的图像。 Cypress.io 有自己的 docker 镜像,但它们无法在我组织的 Jenkins 工作环境中工作。这是添加到 Dockerfile 的代码。
我发现使用 Dockerfile 添加 Cypress 依赖项更容易:
# Image installing Cypress Test Runner system dependencies
RUN apt-get update && \
apt-get install --no-install-recommends -y \
# install cypress system dependencies
libgtk2.0-0 \
libgtk-3-0 \
libnotify-dev \
libgconf-2-4 \
libgbm-dev \
libnss3 \
libxss1 \
libasound2 \
libxtst6 \
tidy \
xauth \
xvfb \
# clean up
&& rm -rf /var/lib/apt/lists/*
RUN chown jenkins:jenkins -R /home/jenkins
RUN sh -c "echo 'Cypress Build image maintained by Raccoons' >> /build_image.info"
USER jenkins
RUN echo "NODE_VERSION: $NODE_VERSION" \
&& echo "NVM_DIR: $NVM_DIR" \
# NVM install
&& . $NVM_DIR/nvm.sh \
# NPM and Node install
&& nvm install $NODE_VERSION \
# cypress install
echo "CYPRESS_VERSION: $CYPRESS_VERSION" \
&& npm install -g cypress@$CYPRESS_VERSION \
&& cypress verify \
&& cypress info