I need to know how to write a Jenkins job which polls a GitHub repository continuously and send an email of commits made to that repo.
1 Answer
Considering you have proper credentials in Jenkins and admin right for Git repo, Create a webhook between Jenkins and your Git repo. Webhook will help you push (reverse poll)the commits. You can use jenkins DSL (groovy) to operate on that Git repo by using Git commands. You can use specific Git commands to list Authors of last commits (or any other requirement) and Use email-ext (or any other) plugin in jenkins to be able to send email through DSL.
One line reference to list Author (yeah..it works as it is in any Git repo)-
git log -1 --pretty=format:'%an'
My reference of email to culprits if something goes wrong my jenkins build
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])])