Build step 'Execute shell' marked build as failure

Hey guys,
I tried to configure a new project to load a repository from Github with my automated tests written in Cypress. Of course, I didn’t insert node_modules because of their size, so in the build steps I gave it to execute a shell command such as npm install (to install the modules needed for Cypress) and npm run checkbox (the command to run the automated test, defined in package.json/scripts). Unfortunately, however, it throws me the following error: Build step ‘Execute shell’ marked build as failure. Do any of you perhaps know what could be the cause? I think I’ve looked everywhere…

Here is console output:

Started by user Dawid Łaciak

Running as SYSTEM
Building in workspace C:\Users\dawid\.jenkins\workspace\Cypress Automated Tests
The recommended git tool is: NONE
No credentials specified
 > C:\Program Files\Git\bin\git.exe rev-parse --resolve-git-dir C:\Users\dawid\.jenkins\workspace\Cypress Automated Tests\.git # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files\Git\bin\git.exe config remote.origin.url https://github.com/dawidlaciak/automated-tests.git # timeout=10
Fetching upstream changes from https://github.com/dawidlaciak/automated-tests.git
 > C:\Program Files\Git\bin\git.exe --version # timeout=10
 > git --version # 'git version 2.47.1.windows.1'
 > C:\Program Files\Git\bin\git.exe fetch --tags --force --progress -- https://github.com/dawidlaciak/automated-tests.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/main^{commit}" # timeout=10
Checking out Revision abc40e700a39cacd40ec88bdb9e1eb8e436e356e (refs/remotes/origin/main)
 > C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files\Git\bin\git.exe checkout -f abc40e700a39cacd40ec88bdb9e1eb8e436e356e # timeout=10
Commit message: "Automated Cypress Tests"
 > C:\Program Files\Git\bin\git.exe rev-list --no-walk abc40e700a39cacd40ec88bdb9e1eb8e436e356e # timeout=10
[Cypress Automated Tests] $ /bin/sh C:\Users\dawid\AppData\Local\Temp\jenkins4979169135057120745.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
	at java.base/java.lang.ProcessImpl.create(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:500)
	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1126)
Caused: java.io.IOException: Cannot run program "/bin/sh" (in directory "C:\Users\dawid\.jenkins\workspace\Cypress Automated Tests"): CreateProcess error=2, The system cannot find the file specified
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1089)
	at hudson.Proc$LocalProc.<init>(Proc.java:252)
	at hudson.Proc$LocalProc.<init>(Proc.java:221)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:994)
	at hudson.Launcher$ProcStarter.start(Launcher.java:506)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:144)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:92)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:818)
	at hudson.model.Build$BuildExecution.build(Build.java:199)
	at hudson.model.Build$BuildExecution.doRun(Build.java:164)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:527)
	at hudson.model.Run.execute(Run.java:1831)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:445)
Build step 'Execute shell' marked build as failure
Finished: FAILURE

you used the shell step, that is intended for Unix machines. But you’re on windows. Try using the windows bat script step

I changed it into Execute Windows batch command and it still doesn’t work. I get the same output:

Running as SYSTEM
Building in workspace C:\Users\dawid\.jenkins\workspace\Testy automatyczne w Cypress
The recommended git tool is: NONE
No credentials specified
 > C:\Program Files\Git\bin\git.exe rev-parse --resolve-git-dir C:\Users\dawid\.jenkins\workspace\Testy automatyczne w Cypress\.git # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files\Git\bin\git.exe config remote.origin.url https://github.com/dawidlaciak/testy-automatyczne.git # timeout=10
Fetching upstream changes from https://github.com/dawidlaciak/testy-automatyczne.git
 > C:\Program Files\Git\bin\git.exe --version # timeout=10
 > git --version # 'git version 2.47.1.windows.1'
 > C:\Program Files\Git\bin\git.exe fetch --tags --force --progress -- https://github.com/dawidlaciak/testy-automatyczne.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/main^{commit}" # timeout=10
Checking out Revision abc40e700a39cacd40ec88bdb9e1eb8e436e356e (refs/remotes/origin/main)
 > C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files\Git\bin\git.exe checkout -f abc40e700a39cacd40ec88bdb9e1eb8e436e356e # timeout=10
Commit message: "Testy automatyczne Cypress"
 > C:\Program Files\Git\bin\git.exe rev-list --no-walk abc40e700a39cacd40ec88bdb9e1eb8e436e356e # timeout=10
[Testy automatyczne w Cypress] $ cmd /c call C:\Users\dawid\AppData\Local\Temp\jenkins12946481904164965759.bat

C:\Users\dawid\.jenkins\workspace\Testy automatyczne w Cypress>npm install  
npm error Class extends value undefined is not a constructor or null
npm error A complete log of this run can be found in: C:\Users\dawid\AppData\Local\npm-cache\_logs\2024-12-26T09_03_39_062Z-debug-0.log
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

The error is completely different now. Seems to be not related to Jenkins.

C:\Users\dawid\.jenkins\workspace\Testy automatyczne w Cypress>npm install  
npm error Class extends value undefined is not a constructor or null
npm error A complete log of this run can be found in: C:\Users\dawid\AppData\Local\npm-cache\_logs\2024-12-26T09_03_39_062Z-debug-0.log

Have you checked what is in that log?

My bad, I didn’t notice this line.
Here is what this log contains:

0 verbose cli C:\Users\dawid\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\nodejs\node.exe C:\Users\dawid\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\nodejs\node_modules\npm\bin\npm-cli.js
1 info using npm@10.9.0
2 info using node@v22.12.0
3 silly config load:file:C:\Users\dawid\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\nodejs\node_modules\npm\npmrc
4 silly config load:file:C:\Users\dawid\.jenkins\workspace\Testy automatyczne w Cypress\.npmrc
5 silly config load:file:C:\Users\dawid\.npmrc
6 silly config load:file:C:\Users\dawid\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\nodejs\etc\npmrc
7 verbose title npm install
8 verbose argv "install"
9 verbose logfile logs-max:10 dir:C:\Users\dawid\AppData\Local\npm-cache\_logs\2024-12-26T09_03_39_062Z-
10 verbose logfile C:\Users\dawid\AppData\Local\npm-cache\_logs\2024-12-26T09_03_39_062Z-debug-0.log
11 silly logfile start cleaning logs, removing 1 files
12 verbose stack TypeError: Class extends value undefined is not a constructor or null
12 verbose stack     at Object.<anonymous> (C:\Users\dawid\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\nodejs\node_modules\npm\node_modules\minipass-collect\index.js:4:23)
12 verbose stack     at Module._compile (node:internal/modules/cjs/loader:1565:14)
12 verbose stack     at Object..js (node:internal/modules/cjs/loader:1708:10)
12 verbose stack     at Module.load (node:internal/modules/cjs/loader:1318:32)
12 verbose stack     at Function._load (node:internal/modules/cjs/loader:1128:12)
12 verbose stack     at TracingChannel.traceSync (node:diagnostics_channel:322:14)
12 verbose stack     at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
12 verbose stack     at Module.require (node:internal/modules/cjs/loader:1340:12)
12 verbose stack     at require (node:internal/modules/helpers:138:16)
12 verbose stack     at Object.<anonymous> (C:\Users\dawid\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\nodejs\node_modules\npm\node_modules\cacache\lib\get.js:3:17)
13 error Class extends value undefined is not a constructor or null
14 verbose cwd C:\Users\dawid\.jenkins\workspace\Testy automatyczne w Cypress
15 verbose os Windows_NT 10.0.26100
16 verbose node v22.12.0
17 verbose npm  v10.9.0
18 verbose exit 1
19 verbose code 1
20 error A complete log of this run can be found in: C:\Users\dawid\AppData\Local\npm-cache\_logs\2024-12-26T09_03_39_062Z-debug-0.log

Okay, so I have no idea what is going on. Now I changed it back to “Execute Shell” and used it with the same commands as before and it passed, but I didn’t receive any output about result of tests (command npm run checkbox).

And when I use command npm run checkbox locally it gives me step-by-step result about tests. I have no idea what am i doing wrong.