Search code examples
jenkinsjenkins-pipelinecypressyarnpkg

Cypress run command not running during Jenkins build


I am in the process of running an integration in Jenkins. The gist of the problem is as follows:

I have cloned a git of the application I am to working on into my workstation, then created a directory, initialised it in git and yarn, then installed cypress in it.

I then entered the following lines in the pertinent Jenkinsfile:

yarn install
.
.
.
cd (testing-directory)
yarn run cypress run --browser chrome --headless

At this point, the build fails.

The error message I get is:

error Command "cypress" is not found.

However, the command yarn run cypress run --browser chrome --headless runs perfectly on the cypress installation in the instance of this git in my local machine.

Please advise how I can have this command run during the Jenkins build.


Solution

  • I managed to solve this problem. I needed to have Jenkins install Cypress in the build.

    Hence I added the line:

    yarn add cypress --dev -W
    

    It worked and I am on my way again!

    Update: I had (inadvertently) initialised this subfolder as a main package, so it was performing independently of the rest of the folder structure. I deleted the .git folder within and all issues have been solved without having to install cypress all over again.