python - 我可以使用预提交 Hook 在 Java 项目上调用 Maven 构建吗?

标签 python git maven-3 maven-plugin githooks

在将存储库提交到 Git 之前,我需要在本地存储库上触发 Maven 构建。

我需要什么东西?

我是 Git 的新手,所以请给我关于如何执行上述操作的建议。提前致谢

最佳答案

您可以尝试设置一个 pre-commit hook

The pre-commit hook is run first, before you even type in a commit message. It’s used to inspect the snapshot that’s about to be committed, to see if you’ve forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.

在您的情况下,.git/hook/pre-commit 脚本可以触发 Maven 构建:如果该构建失败,则以状态 1 退出并且提交不会完成。

尽管you had trouble making a git pre-commit hook run before ,即使在 Windows 上,也可以从钩子(Hook)调用 python 脚本。
看这个Atlassian example例如。

#!/bin/sh

"C:\Python27\python.exe" "C:\path\to\mytriggers.py" myParams

关于python - 我可以使用预提交 Hook 在 Java 项目上调用 Maven 构建吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25225458/

相关文章:

java - 如何使用 Maven 分析依赖项

Maven 程序集插件警告 "The assembly descriptor contains a filesystem-root relative reference"

python - 检查 IP 地址

python - 没有输入坐标时的验证

python - 用于解析平面 XML 的优雅 Python 循环

git - 重命名本地和远程 Git 存储库的 master 分支

Maven -pl !<module> 不会从构建中排除 <module> 的子模块

python - `QTextEdit` 光标在覆盖其 `dropEvent` 后卡住

git - 我必须在 merge 每个文件后退出我的 Git diff 工具吗?

json - 如何从 GitHub 克隆所有 repos(包括私有(private) repos)?