Issue
To run Cypress, it requires that system dependencies be installed, Cypress Dependencies
apt-get install libgtk2.0-0 libgtk-3-0 libnotify-dev
libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
To run Cypress script in local Jenkins, I am creating a Jenkinsfile
.
Jenkinsfile has a stage command npx cypress run
in Jenkins, and it fails "Your system is missing the dependency: Xvfb"
.
First thought was to install npm package xvfb, and that did not resolve the problem.
Then, I installed through local Jenkins, Jenkins plugin Xvfb, and this worked!
My goal is to run Cypress on a remote Jenkins, and it fails the same way "Your system is missing the dependency: Xvfb"
.
Important note: I do not have access to remote Jenkins service and command Manage Plugins to request install of Jenkins plugin Xvfb.
Since it was not clear how to install Jenkins plugin Xvfb through Jenkinsfile
, I tried shell scripting within Jenkinsfile
. Each system package appear to install except xvfb
, so this approach of install to remote Jenkins service did not work.
sh 'sudo apt-get install libgtk2.0-0 libgtk-3-0
libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
libxtst6 xauth xvfb -y'
Is anyone aware to script Jenkinsfile
to install Jenkins plugin Xvfb before running npm installs?
Thank you, much appreciate your assistance
Solution
I have resolved this by creating a docker file in which it image is used by Jenkinsfile. Cypress.io has its own docker images but they cannot work in my organization's Jenkins jobs environment. Here is the code added to Dockerfile.
I found it was easier to add Cypress dependencies using Dockerfile:
# 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
Answered By - Jeff Tanner