1

pre-commit is a great tool and id like to incorporate it into jenkins pipelines just to make sure someone didn't try to skip it during committing to the repo.

so my questions are:

  • what are the best practices to initialize pre-commit? (just initialize it as i would in the repo? the website offers examples for some other CI integrations but not jenkins)
  • how can i say to jenkins to stop the build if any of the tests performed by pre-commit fails? (exit code? which one would be success or fail?
anthony sottile
  • 61,815
  • 15
  • 148
  • 207

1 Answers1

6

as the docs indicate the best way to run pre-commit in a CI system is with pre-commit run, usually pre-commit run --all-files --show-diff-on-failure

this will exit nonzero which should fail your pipeline as desired


disclaimer: I'm the creator of pre-commit

anthony sottile
  • 61,815
  • 15
  • 148
  • 207