How to get culprits or committers inside a Jenkins workflow with one or more SCMs
This is now possible using the email-ext plugin.
def to = emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']])if (to != null && !to.isEmpty()) { mail to: to, subject: "JENKINS", body: "See ${env.BUILD_URL}"}
However, if you just want to send an email on failures, you may want to use Mailer (based on the email-ext pipeline examples):
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])])
Using groovy within a pipeline script:
@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}
similar to the answer from @szym, but without the @NonCPS
required:
def authors = currentBuild.changeSets.collectMany { it.toList().collect { it.author } }.unique()