I am trying to use husky to install git hooks as part of a Jenkins pipeline job.
I've added this to the Jenkins job:
npm install husky --save-dev
But when the job runs I see this in the Jenkins output:
> node-sass@4.14.1 install /home/jenkins/agent/workspace/<branch_name>/node_modules/node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux_musl-x64-72_binding.node
Download complete
Binary saved to /home/jenkins/agent/workspace/<branch_name>/node_modules/node-sass/vendor/linux_musl-x64-72/binding.node
Caching binary to /root/.npm/node-sass/4.14.1/linux_musl-x64-72_binding.node
> husky@4.3.0 install /home/jenkins/agent/workspace/<branch_name>/node_modules/husky
> node husky install
husky > Setting up git hooks
CI detected, skipping Git hooks installation.
husky > Done
... and the .git/hooks/precommit hook file is never created.
Troubleshooting research notes:
In the husky v4 documentation it says "By default, Husky won't install on CI servers." I can't find any documentation on how to override that default behavior.
I can't even find the "CI detected, skipping Git hooks installation" string in the code when searching the repo code.
I've found an issue in the husky repo from 2017 where the developer explains why husky doesn't install in CI but did not explain how to override that, instead indicating they'd be interested in hearing about use cases for running husky in CI (implying that at least in 2017 there was no way to override).
In this blog post from June 2019 the author implies that husky simply cannot be run in CI and that it uses is-ci to detect whether it's running on a CI server.
is-ciis mentioned in the husky documentation here where they suggest using it to detect if husky is running in CI and useHUSKY=0to disable it. However, the behavior I'm experiencing is that husky is already not running in CI. I've tried settingHUSKY=1in the Jenkins job but that has no effect.