Integration Of Cypress with jenkins

Reading Time: 3 minutes

Hello everyone, I hope you all are safe and sound, as in my previous blog we have already covered some frontend and backend testing scenarios with cypress. In this blog, we will talk about the Integration of Cypress with Jenkins.

So, the agenda of this blog will be like:

  • Jenkins Installation (Ubuntu)
  • Integration Of Cypress with Jenkins
  • Execution with Jenkins

Jenkins Installation:

For installing Jenkins on our local system, all we need to do hit some commands from our terminal and we are all set to work with Jenkins

First of all, we will add this Debian package repository of Jenkins, and to use this repository we will add the key to our system.

$wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

Then we will add the following entry in our /etc/apt/sources.list:

deb https://pkg.jenkins.io/debian-stable binary/

At the end we will update our local package index, then finally we will install Jenkins:

sudo apt-get update
sudo apt-get install jenkins

Integration Of Cypress with jenkins:

  • After Installing Jenkins we need to open Jenkins at http://localhost:8080/, here we will be able to see the Jenkins dashboard.
  • Once the Dashboard is open, we will click on a new item but in the top left corner of the Dashboard. It will open a new pop-up window where we can set up our project.
  • In this window, we will provide any name to the newly added build, and select the type of build. We can choose any option as per our requirement.
  • After selecting the freestyle project we will click on the OK button, this action will redirect us to another window where we need to configure our project.
  • In the next step, we need to click on the advanced button and provide the path of our workspace directory and a display name to our build.
  • Now we will click on add build step and select the execute shell option from the drop-down menu.
  • After selecting the build step, we can write our script in execute shell’s command section. For executing all the tests file we can add the command “npx cypress run” in command section.
  • After writing the script, we will click on apply and save button. Once we will save the configuration we will be able to see a new build added on the dashboard.
  • The most important step, As we know that after running the command “npx cypress run”, it will execute all the test files present in integrations directory and will save the report and the video in the mochawesome-report and video directory respectively. So for that we need to provide the create and delete permission to the current user. For this we can use the command:
sudo chmod -R +rwx CypressTestDemo/cypress/
  • Now we are all set to run our first cypress build with Jenkins:

Thanks for reading, In our next blog, We will introduce some more cool features of Jenkins which we can use with cypress.

References:

https://www.jenkins.io/download/
https://docs.cypress.io/guides/overview/why-cypress.html

Knoldus-blog-footer-image

Written by 

Vandana is a Sr. QA Consultant having experience of more than 2.5 years. She is familiar with the core concepts of manual and automation, postman and Newman are her expertise. She is always eager to learn new and advance concepts in order to expand her horizon and apply them in project development with her existing knowledge. Her hobbies include reading novels and listening to music.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading