2

I've got a deploy process set up in jenkins, which first installs the entire JavaScript app locally on the jenkins server, starts grunt for testing/building the app, and copies everything over to a staging machine afterwards.

Yesterday I noticed that I had a typo in my package.json and npm failed to install an updated module, thus throwing a warning.

Jenkins seems to have noticed that issue and marked the build as UNSTABLE, but kept on deploying (Post-Build tasks using ssh-copy plugin).

Is there a way to stop a build process when NPM fails to install a module?

Steffen
  • 589
  • 6
  • 16

1 Answers1

5

you can try

npm install || exit 1

What this command says is if the "npm install" command didn't run successfully (didn't return exit code of 0) then "exit 1"

For reference: How to exit if a command failed?

Community
  • 1
  • 1
Ali
  • 473
  • 2
  • 7