title: Install husky git hooks in Jenkins pipeline job by overriding "CI detected, skipping Git hooks installation"
body: <p>I am trying to use <a href="https://github.com/typicode/husky" rel="nofollow noreferrer">husky</a> to install git hooks as part of a Jenkins pipeline job.</p>
  <p>I've added this to the Jenkins job:</p>
  <pre><code>npm install husky --save-dev
  </code></pre>
  <p>But when the job runs I see this in the Jenkins output:</p>
  <pre><code>&gt; node-sass@4.14.1 install /home/jenkins/agent/workspace/&lt;branch_name&gt;/node_modules/node-sass
  &gt; 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/&lt;branch_name&gt;/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
  
  &gt; husky@4.3.0 install /home/jenkins/agent/workspace/&lt;branch_name&gt;/node_modules/husky
  &gt; node husky install
  
  husky &gt; Setting up git hooks
  CI detected, skipping Git hooks installation.
  husky &gt; Done
  </code></pre>
  <p>... and the <code>.git/hooks/precommit</code> hook file is never created.</p>
  <p>Troubleshooting research notes:</p>
  <ul>
  <li><p>In the <a href="https://github.com/typicode/husky/tree/master#ci-servers" rel="nofollow noreferrer">husky v4 documentation</a> it says <em>&quot;By default, Husky won't install on CI servers.&quot;</em> I can't find any documentation on how to override that default behavior.</p>
  </li>
  <li><p>I can't even find the <em>&quot;CI detected, skipping Git hooks installation&quot;</em> string in the code when  <a href="https://github.com/typicode/husky/search?q=CI%20detected&amp;type=code" rel="nofollow noreferrer">searching the repo code</a>.</p>
  </li>
  <li><p>I've found an <a href="https://github.com/typicode/husky/issues/189" rel="nofollow noreferrer">issue</a> 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).</p>
  </li>
  <li><p>In this <a href="https://www.vojtechruzicka.com/githooks-husky/#continuous-integration" rel="nofollow noreferrer">blog post</a> from June 2019 the author implies that husky simply cannot be run in CI and that it uses <a href="https://github.com/watson/is-ci" rel="nofollow noreferrer">is-ci</a> to detect whether it's running on a CI server. <code>is-ci</code> is mentioned in the husky documentation <a href="https://github.com/typicode/husky/blob/98997a9299cbe14ca88884ae5ac8f845b6b780bf/docs/README.md#disable-hooks-in-ci" rel="nofollow noreferrer">here</a> where they suggest using it to detect if husky is running in CI and use <code>HUSKY=0</code> to disable it. However, the behavior I'm experiencing is that husky is already not running in CI. I've tried setting <code>HUSKY=1</code> in the Jenkins job but that has no effect.</p>
  </li>
  </ul>