get_author_email.sh 495 B

12345678910111213
  1. #!/bin/bash
  2. # author emaill will be jenkins's email, when the pr branch is not fast forward compared with master branch
  3. # Exit immediately for non zero status
  4. set -e
  5. function get_author_email(){
  6. email=$(git --no-pager show -s --format=\'%ae\' HEAD )
  7. # Get last commit author when Jenkins submit a merge commit
  8. if [[ "${email}" == \'nobody@nowhere\' ]]; then
  9. email=$(git --no-pager show -s --format=\'%ae\' HEAD^ )
  10. fi
  11. echo ${email} | sed $'s/\'//g'
  12. }
  13. get_author_email