title: Jenkins send e-mail notification to github committers
body: <p>We want to send out e-mail notifications to our contributors if the Jenkins build was successful or not.</p>
  <p>we are using the email extension plugin: <a href="https://plugins.jenkins.io/email-ext/" rel="nofollow noreferrer">https://plugins.jenkins.io/email-ext/</a></p>
  <p>Notifications should be sent in the following cases:</p>
  <ul>
  <li>The current build failed or is unstable</li>
  <li>the current build is successful and the previous build failed or was unstable</li>
  </ul>
  <p>I created a shared library with the following script</p>
  <pre><code>#!/usr/bin/env groovy
  
  def call(String buildStatus = 'STARTED') {
      
      buildStatus = buildStatus ?: 'SUCCESS'
  
    
      def subject = &quot;JENKINS NOTIFICATION - ${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'&quot;
      def details = &quot;&quot;&quot;${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'&quot;&quot;&quot;
  
      // Send email to user who has started the build
      emailext(
          subject: subject,
          body: details,
          attachLog: true,
          compressLog: true,
          recipientProviders: [[$class: 'RequesterRecipientProvider'], [$class: 'CulpritsRecipientProvider']]
      )
  }
  </code></pre>
  <p>In the Jenkinsfile I loaded the library <code>shared-lib</code> and I defined the <code>sendNotification</code> command in the post-block of the jenkinsfile:</p>
  <pre><code>#!groovy
  @Library('shared-lib') _
  
  pipeline {
      agent any
      stages{
          stage('Checkout code base'){
              steps{
                  checkout scm
              }
          }
          stage('another stage'){
              steps{
                  echo &quot;do something&quot;
              }
          }
  
      }
      post{
          always{
              sendNotifications currentBuild.result
          }
      }
  }
  </code></pre>
  <p>Currently, the e-mail notifications are sent when I manually trigger a build at Jenkins, but when I push to GitHub and Jenkins build gets triggered, no e-mail notification is sent.</p>
  <p>This is the log of the pipeline:</p>
  <pre><code>19:12:06  [Pipeline] emailext
  19:12:06  Sending mail from default account using System Admin e-mail address
  19:12:06  messageContentType = text/plain; charset=UTF-8
  19:12:06  Request made to attach build log
  19:12:06  Request made to compress build log
  19:12:06  Adding recipients from project recipient list
  19:12:06  Not sending mail to user noreply-github+ms@companyname.com with no permission to view NewSimple » MTEvent » master #203  Collecting change authors...
  19:12:06      build: 203
  19:12:06        adding author: noreply-github+ms
  19:12:06  Not sending mail to user noreply-github+ms@companyname.com with no permission to view NewSimple » MTEvent » master #203Adding recipients from trigger recipient list
  19:12:06  Successfully created MimeMessage
  19:12:06  An attempt to send an e-mail to empty list of recipients, ignored.
  </code></pre>
  <p>PS: I don't know from where this email <strong>noreply-github+ms@companyname.com</strong> was pickup.
  The correct email address should be myfirstname.lastname@companyname.com</p>
  <p>Not sure what I have missed.</p>
  <p>Any suggestions would be appreciated.</p>