0

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.

0

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']])])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.