我正在尝试使用 husky安装 git hooks 作为 Jenkins 管道作业的一部分。
我已将此添加到 Jenkins 工作中:
npm install husky --save-dev
但是当作业运行时,我在 Jenkins 输出中看到了这一点:> 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
... 和 .git/hooks/precommit
钩子(Hook)文件永远不会被创建。故障排除研究笔记:
is-ci
赫斯基文档中提到了here他们建议使用它来检测 husky 是否在 CI 中运行并使用 HUSKY=0
禁用它。但是,我遇到的行为是 husky 已经没有在 CI 中运行。我试过设置 HUSKY=1
在 Jenkins 的工作中,但这没有效果。最佳答案
对于路人来说,这个问题仍然与 husky 4+ 相关。在 CI 系统中,您可以运行:
export HUSKY_SKIP_INSTALL=1
例如:docker
ENV HUSKY_SKIP_INSTALL=1
亚搏体育app CIbuild:
script:
- export HUSKY_SKIP_INSTALL=1
- npm install
GitHub 工作流jobs:
build:
steps:
env:
HUSKY_SKIP_INSTALL: 1
Jenkins Create a global property .
关于git - 通过覆盖 "CI detected, skipping Git hooks installation"在 Jenkins 管道作业中安装 husky git hooks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64724492/