从一个或多个SCM(通过checkout()或其他SCM步骤如git/svn)检出时,是否可以访问有关Jenkins工作流作业的提交者和/或罪犯的信息?
目的是使用该信息来通知提交者和/或罪犯有关工作状态的信息,例如在一个mail
步骤中.
工作流定义的一个小示例:
node { // checkout from one or more SCMs, e.g. git 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: ' ' }
在运行SCM步骤之后,如何调整它以获取提交者的集合?
编辑:我目前正在使用Jenkins版本1.596.2和Workflow:Aggregator版本1.6,这似乎是JENKINS-24141中的一个未解决的问题
现在可以使用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管道示例):
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])])
在管道脚本中使用groovy:
@NonCPS // Necessary to allow .each to work. def changelist() { def changes = "" currentBuild.changeSets.each { set -> set.each { entry -> changes += "${entry.commitId} by ${entry.author.fullName}\n" } } changes }