Jenkins的Git插件:如何设置env变量GIT_AUTHOR_EMAIL和GIT_COMMITTER_EMAIL? [英] Git plugin for Jenkins: How do I set env variables GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL?

查看:2507
本文介绍了Jenkins的Git插件:如何设置env变量GIT_AUTHOR_EMAIL和GIT_COMMITTER_EMAIL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试设置环境变量 GIT_AUTHOR_EMAIL GIT_COMMITTER_EMAIL ,以便Jenkins的GIT插件声称设置( https://wiki.jenkins-ci.org/display/JENKINS / GIT中+插件)。

I have been trying to set the environment variables GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL so that the GIT plugin for Jenkins claims to be setting(https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin).

我看到其余的环境变量即可。 GIT_URL GIT_BRANCH GIT_COMMIT GIT_PREVIOUS_COMMIT 被准确地设置为每个jenkins作业。

I see that the rest of the environment variables viz. GIT_URL, GIT_BRANCH, GIT_COMMIT, GIT_PREVIOUS_COMMIT are set accurately for each of the jenkins jobs.

我正在通过使用 printenv 在jenkins作业shell脚本构建步骤中打印所有环境变量来测试。

I am testing this by printing out all the environment variables in a jenkins jobs shell script build step by using printenv.

有人可以让我知道,如果我在这里缺少一些东西吗?
这是我可以想到的几个可能的原因..

Can somebody please let me know if I am missing something here ? Here are few of the possible reasons that I could think of..


  1. 插件错误

  2. Jenkins设置/配置问题

  3. Github中的GIT配置问题。



请帮助我在这方面。

Please help me in this regard.

谢谢!

p.s。我也看到一个类似的问题没有得到答复( Github-plugin for Jenkins得到提交者和作者姓名

p.s. I also saw a similar question is left unanswered (Github-plugin for Jenkins get committer and author name)

推荐答案

实际上,当您覆盖作者姓名和作者在SCM配置的高级功能上发送电子邮件。

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

其他行为 - > em>自定义用户名/电子邮件地址

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

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

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)

正在 $ GIT_COMMIT SHA1提交ID。

Being $GIT_COMMIT the SHA1 commit id.

这篇关于Jenkins的Git插件:如何设置env变量GIT_AUTHOR_EMAIL和GIT_COMMITTER_EMAIL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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