6

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

Jeff
  • 1,917
  • 1
  • 25
  • 43
  • 1
    without running the above config inside Jenkins. Isn't there a way for you to run the command inside the server itself? – Muditha Perera Aug 07 '20 at 10:01
  • 1
    Your method of using the shell script is what I've used in the past. I suggest double checking the output from that install command. You might need another package besides xvfb depending on your OS. – olore Apr 13 '21 at 01:19
  • I have resolved this problem by applying dependences within a Dockerfile and importing the created image to Jenkinsfile. Thank you for your response. – Jeff Apr 13 '21 at 22:46

1 Answers1

2

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
Jeff
  • 1,917
  • 1
  • 25
  • 43