Configure Cypress on Jenkins

Muditha
3 min readJul 17, 2020

Cypress has become one of the fast-growing test automation framework in the software industry. As you learn cypress you would probably come across the need to integrate your cypress tests with your CI environment. So let’s see how we can do using Jenkins.

Step 1: Add NodeJs plugin

As you know, we need Node.js to run cypress. So as the first step, we will install Nodejs in our Jenkins environment. In Jenkins, go to

Manage Jenkins > Manage Plugins > Available Plugins and search for NodeJS Plugin and add it.

Step 2: Add NodeJs Installation

After you successfully added the NodeJs Plugin, you need to add a NodeJs installation to it. To do that go to

Manage Jenkins > Global Tool Configuration and click Add NodeJS. Then,

  • Give a name for your NodeJS installation Eg: Node12
  • Tick the Install automatically Install automatically
  • Select a cypress compatible NodeJS version Eg: NodeJs 12.16.3
  • Add cypress for Global npm packages to install
  • You can keep the other configurations as it is
NodeJS Global Tool Config

Step 3: Create your Jenkins project

Now you need to create your Jenkins project. To keep things simple let’s create a freestyle project. In Jenkins click New Item, give a project name and select Freestyle project

I assume you have your project in git. So, In Source Code Management add your git URL and credentials for the cypress project. If you do not use git I recommend you to move to git as it’s going to help you a lot in managing your code.

Jenkins git config

Step 4: Add Build Environment

Now you need to move to the build environment section. There you will find and select the option, Provide Node & npm bin/ folder to PATH. This is where we set our NodeJS environment to run cypress. If you remember, we added a NodeJs installation in step 2. You will see the name you gave to the installation in NodeJS Installation dropdown. Select it and you can keep the other configurations as it is.

Adding NodeJS Build Environment

Step 5: Add external dependencies (linux / CenOS)

If your Jenkins server OS is windows, you are all set. If not for Linux uses you need to add the following configurations

$ apt-get install libgtk2.0–0 libgtk-3–0 libnotify-dev libgconf-2–4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb

If you are on centOS

$ yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-devel GConf2 nss libXScrnSaver alsa-lib

Find more details on, cypress CI

Step 6: Final step — BUILD !!

Now you are all set. You just need to add your cypress command to execute your script.

Jenkins build

Now you can build it by clicking Build Now

Jenkins console

Let’s talk about cross-browser testing and reporting in another article.

Thank you

--

--

Muditha

Senior Software Automation Engineer from Intervest Software Technologies and a Technology enthusiastic who love to explore new technologies.