git - 如何使用 jenkins 修改 git -commit 消息?
问题描述
我正在使用 Jenkins 服务器来检查主服务器上的构建和合并。现在我想实现它,以便它使用自定义字符串修改提交消息。具体例子:假设我在一个分支上做了 3 次提交;
commit #3
commit #2
commit #1
我想做的是更改这些消息,使它们看起来像
ISSUE-XX commit #3
ISSUE-XX commit #2
ISSUE-XX commit #1
其中 XX 将由用户触发 jenkins 构建完成。有没有办法做到这一点?到目前为止,我还没有在网上找到答案。
我已经考虑过实现 git-hooks 但这并不是我想要的,我也考虑过自动变基,但我不太明白。
解决方案
使用下面的脚本解决了挤压问题。该解决方案将最后一个 (NUMBER_OF_COMMITS) 压缩为一个作为构建参数给出的单个,并设置自定义提交消息,也作为构建参数给出。
::Rebasing to modify commit messages
:: Reset the current branch to the commit just before the last 12:
git reset --hard HEAD~%NUMBER_OF_COMMITS%
:: HEAD@{1} is where the branch was just before the previous command.
:: This command sets the state of the index to be as it would just
:: after a merge from that commit:
git merge --squash HEAD@{1}
:: Commit those squashed changes.
git commit -m "%ISSUE%"
推荐阅读
- django - API 转换:从 GraphQL 到 REST(使用 Django)
- laravel - 如何在 laravel 中将数据插入数据库但前面有固定字符?
- python-3.x - 将 sns.FacetGrid() 与自定义函数组合时规范化图例外观
- sql - 自动化数据管理
- javascript - 如何在不使用间隔的情况下收听 document.hasFocus()?
- python-3.x - 将大型内存结构写入内存资源有限的磁盘(Python)
- java - 使用 Flink 同步处理 2 个流
- proc-sql - 在后续公式中使用计算值
- django - 如何更改 selectDate django 小部件上的日期格式?
- python - 如何使用请求将 URL 中的日历选择作为标头发送?