Emp*_*yee 5 git continuous-integration pre-commit-hook jenkins husky
我正在尝试使用husky安装 git hooks 作为 Jenkins 管道作业的一部分。
我已将其添加到 Jenkins 作业中:
npm install husky --save-dev
Run Code Online (Sandbox Code Playgroud)
但是当作业运行时,我在 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
Run Code Online (Sandbox Code Playgroud)
...并且.git/hooks/precommit钩子文件永远不会创建。
故障排除研究笔记:
在husky v4 文档中,它说“默认情况下,Husky 不会安装在 CI 服务器上”。我找不到任何有关如何覆盖该默认行为的文档。
在搜索 repo 代码时,我什至无法在代码中 找到“检测到 CI,跳过 Git hooks 安装”字符串。
我在 2017 年的 husky 仓库中发现了一个问题,开发人员解释了为什么 husky 没有在 CI 中安装,但没有解释如何覆盖它,而是表示他们有兴趣了解在 CI 中运行 husky 的用例(这意味着至少在 2017 年没有办法重写)。
在 2019 年 6 月的这篇博文中,作者暗示 husky 根本无法在 CI 中运行,它使用is-ci来检测它是否在 CI 服务器上运行。在 husky 文档中is-ci提到,他们建议使用它来检测 husky 是否在 CI 中运行,并使用它来禁用它。然而,我遇到的行为是 husky 已经没有在 CI 中运行。我尝试过在詹金斯工作中进行设置,但没有效果。HUSKY=0HUSKY=1
对于路人来说,这个问题仍然与哈士奇4+相关。在 CI 系统中你可以运行:
export HUSKY_SKIP_INSTALL=1
Run Code Online (Sandbox Code Playgroud)
例如:
ENV HUSKY_SKIP_INSTALL=1
Run Code Online (Sandbox Code Playgroud)
export HUSKY_SKIP_INSTALL=1
Run Code Online (Sandbox Code Playgroud)
ENV HUSKY_SKIP_INSTALL=1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3898 次 |
| 最近记录: |