Search code examples
jenkinscontinuous-integrationjenkins-pipelinemercurialjenkins-email-ext

How To Send an email from Jenkins to the email of the developer who made the changes on the repo(i.e committing or pushing)?


So my goal is to have Jenkins send an email to developer who was involved with any code changes in the repo in Mercurial. I have set up my hooks on Mercurial and now whenever I do any sort of changes on the repo a build executes on Jenkins which builds without any issue. The problem now is its only sending it to the email that I have configured in Jenkins and not the email of the developer who made the changes. On Mercurial I made sure to make the user the email I primarily use. I was pretty sure the code below would be able to access the email of the developer who made the changes:

pipeline {
   agent any

   stages {
      stage('Hello') {
         steps {
            echo 'Hello World'
         }
      }
   }

   post {
    always {
    emailext body: 'A Test EMail', recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']], subject: 'Test'
    }
}
}

Given that it hasnt I am suspecting that Jenkins is not aware of the email of the developer who made the changes. How do I tell Jenkins about the email of the developer who made the changes? I also made sure to install all of the email plugins for Jenkins btw but still no luck.


Solution

  • I think you are looking for the Email Extension plugin.

    Lets you configure for "Default Recipients", "Developers", "Culprits", "Requester" and more.

    There's also an Email Extension Template plugin available.