Jenkins的Github插件获取提交者和作者姓名 [英] Github-plugin for Jenkins get committer and author name

查看:2302
本文介绍了Jenkins的Github插件获取提交者和作者姓名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我理解的很好,git插件将提交者和作者姓名和电子邮件公开给环境变量 GIT_AUTHOR_NAME GIT_COMMITTER_NAME ,根据git的全局配置, GIT_AUTHOR_EMAIL GIT_COMMITTER_EMAIL 。有没有办法使用Github插件获取该信息? Github插件会暴露负载信息,从github-webhook获取环境变量还是其他内容?

解决方案

实际上,这些变量仅在您覆盖SCM配置的高级功能部件上的作者姓名和作者电子邮件时可用。 其他行为 - > 自定义用户名/电子邮件地址 / em>



这是在源代码中描述的:
https://github.com/jenkinsci/git-plugin/tree/master/src/main/java/hudson / plugins / git





解决方案:和电子邮件,我建议编写脚本:

  GIT_NAME = $(git --no-pager show -s --format ='% '$ GIT_COMMIT)
GIT_EMAIL = $(git --no-pager show -s --format ='%ae'$ GIT_COMMIT)

存在 $ GIT_COMMIT SHA1提交ID


If I understand well, git plugin exposes committer and author names and emails to environmental variables GIT_AUTHOR_NAME, GIT_COMMITTER_NAME, GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL based on the global configuration of git. Is there a way to get that info using Github-plugin? Does Github-plugin exposes payload info, getting from github-webhook, to environmental variables or to something else?

解决方案

In reality these variables are available just when you overwrite the Author Name and Author Email on the Advanced features of the SCM configuration.

"Additional Behaviours" -> "Custom user name/email address"

This is described on the source code: https://github.com/jenkinsci/git-plugin/tree/master/src/main/java/hudson/plugins/git


Solution: In order to retrieve the author name and email I suggest scripting this:

GIT_NAME=$(git --no-pager show -s --format='%an' $GIT_COMMIT)
GIT_EMAIL=$(git --no-pager show -s --format='%ae' $GIT_COMMIT)

Being $GIT_COMMIT the SHA1 commit id.

这篇关于Jenkins的Github插件获取提交者和作者姓名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆