本文介绍了Jenkins Pipeline currentBuild.changeSets和每个存储库检索电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个jenkins管道工作,可以检出3个存储库.
I have a jenkins pipeline job, that check outs 3 repositories.
当构建失败时,根据失败的地方,我想向导致最后一次提交/更改的开发人员发送电子邮件.
When the build fails, depending on where it fails, I want to send emails to the developers which caused the last commits/changes.
我可以用以下方式检索作者的全名:
I can retrieve the authors fullNames with this:
def changeSet = script.currentBuild.changeSets[0];
Set authors = [];
if (changeSet != null) {
for (change in changeSet.items) {
authors.add(change.author.fullName)
}
}
但我不知道:
- 如何获得作者的电子邮件?
- 如何区分不同存储库的作者?
推荐答案
您可以获取作者姓名,然后将其用作邮件注册表中的示例或类似的东西:
You can get the author name and then use it for an example on a mailing registry or something like that:
def author = ""
def changeSet = currentBuild.rawBuild.changeSets
for (int i = 0; i < changeSet.size(); i++)
{
def entries = changeSet[i].items;
for (int i = 0; i < changeSet.size(); i++)
{
def entries = changeSet[i].items;
def entry = entries[0]
author += "${entry.author}"
}
}
print author;
这篇关于Jenkins Pipeline currentBuild.changeSets和每个存储库检索电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!