Alexander Popov
Alexander Popov

Reputation: 24895

Is there a way to get notified when a Jenkins build has finished?

We use Jenkins as a CI platform. We have integrated it with GitHub, so that whenever I open a PR I can see at the bottom whether a build is running (yellow circle), succeeded (green tick) or failed (red cross). The thing is - the build lasts very long and I have to constantly open the PR and look at the status. I was wondering whether:

1) It is possible, that Jenkins sends an email, when a particular build finishes (but I want to get emails only for builds of my pull requests, not for everybody's PRs)?

2) Maybe the Jenkins bot can write a comment in the PR, which in turn will notify me via GitHub notifications?

Can anybody point me to a resource about how this can be setup?

Upvotes: 8

Views: 4767

Answers (1)

Olia
Olia

Reputation: 811

If your build is caused by PR on Github, I would advice you to combine 2 things

  1. Get build trigger information (I guess, this info will show you whether you were PR author etc.). Please, check my answer for the case how to get job cause information: How to handle nightly build in Jenkins declarative pipeline
  2. Then, use Email-ext plugin to conditionally send an email (https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin) This will enable you to conditionally send mail to yourself, so in case you are PR author, just send an email.

Also, in case if you will not be able to extract PR author details from build trigger info, consider using https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin , where Lookup PR detailed information for each PR is supported for sure.

Upvotes: 3

Related Questions