gpt4 book ai didi

git - 你如何为 Jenkins 管道提取 git 提交者信息

转载 作者:太空狗 更新时间:2023-10-29 13:10:46 25 4
gpt4 key购买 nike

我在 groovy 中设置了一个管道,需要 pull 出在 git 中提交某些代码的人,以便我可以发布破坏构建的人名。我在网上搜索过,似乎找不到解决方案。我想出了如何通过使用 jenkins 的 slack 插件在 slack 中发布帖子。示例:

slackSend color: 'warning', message: "${git.user_name} broke the build."

最佳答案

你必须为此使用 shell 并执行 git 命令来检索数据,将其存储在文件中,然后将文件读入变量,如下所示:

sh 'git log --format="%ae" | head -1 > commit-author.txt'                 
readFile('commit-author.txt').trim()

以上将为您提供最后的提交作者。

关于git - 你如何为 Jenkins 管道提取 git 提交者信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37755586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com