jenkins - 如何在具有一个或多个 SCM 的 Jenkins 工作流程中找到罪魁祸首或提交者

标签 jenkins version-control jenkins-workflow jenkins-pipeline

从一个或多个 SCM(通过 checkout() 或其他 SCM 步骤如 git/svn) checkout 时,是否可以访问有关 Jenkins 工作流作业的提交者和/或罪魁祸首的信息?

目的是使用该信息通知提交者和/或罪犯有关作业状态的信息,例如在 mail 中。步。

工作流定义的一个小例子:

node {
  // checkout from one or more SCMs, e.g.
  git url: '<URL>' 
  checkout([$class:...])
  ...

  // how can we know about committers or culprits at this point?
  $committers = ??

  // send a mail to committers or culprits
  mail to: '$committers', subject: 'JENKINS', body: '<information about the job status>'
}

在运行 SCM 步骤后,如何调整以获取提交者的集合?

编辑:
我目前正在使用 Jenkins 1.596.2 版和 Workflow: Aggregator 1.6 版,这似乎是 JENKINS-24141 中的一个 Unresolved 问题

最佳答案

现在可以使用 email-ext插入。

def to = emailextrecipients([[$class: 'CulpritsRecipientProvider'],
                             [$class: 'DevelopersRecipientProvider'],
                             [$class: 'RequesterRecipientProvider']])
if (to != null && !to.isEmpty()) {
    mail to: to, subject: "JENKINS", body: "See ${env.BUILD_URL}"
}

但是,如果您只想发送有关失败的电子邮件,您可能需要使用 Mailer(基于 email-ext pipeline examples):
step([$class: 'Mailer',
      notifyEveryUnstableBuild: true,
      recipients: emailextrecipients([[$class: 'CulpritsRecipientProvider'],
                                      [$class: 'RequesterRecipientProvider']])])

关于jenkins - 如何在具有一个或多个 SCM 的 Jenkins 工作流程中找到罪魁祸首或提交者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30398465/

相关文章:

c# - 未找到 Jenkins NUnit 报告文件

适用于本地和云应用程序的 Azure DevOps CI/CD

java - 如何在基于 alpine 的 docker 容器上安装多个 openjdk 版本

git - 重用 git 存储库的一部分

git - 为什么 git checkout <remote_branchname> 不创建新的跟踪分支?

jenkins - 获取 Jenkins Pipeline 插件中工作区目录的绝对路径

jenkins - 通过Jenkins执行Newman( postman )作业(输出问题)

git - 如何从 RTC Jazz 迁移到 Git?

maven - 在生产中使用 Jenkins 进行 Docker 工作流设计

Jenkins : Passing a parameter from one job to another used Parameterized Trigger Plugin. 不工作