Jenkins Pipeline currentBuild.changeSets 并检索每个存储库的电子邮件 [英] Jenkins Pipeline currentBuild.changeSets and retrieving emails per repository

查看:15
本文介绍了Jenkins Pipeline currentBuild.changeSets 并检索每个存储库的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Jenkins 管道作业,它检查三个存储库.

I have a Jenkins pipeline job, that check outs three 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 full names with this:

def changeSet = script.currentBuild.changeSets[0];
Set authors = [];
if (changeSet != null) {
    for (change in changeSet.items) {
        authors.add(change.author.fullName)
    }
}

但我想不通:

  1. 如何获取作者的电子邮件?
  2. 如何区分不同存储库的作者?

推荐答案

您可以获取作者姓名,然后将其用作邮件注册表或类似的示例:

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 并检索每个存储库的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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