Jenkins sends unnecessary email to all developers for a failed build - jenkins

I am building our SVN trunk repository every hour. I have configured Jenkins to send emails to those developers who broke the build. For some reason, Jenkins seems to send email to any developer who has ever at any point committed to SVN. I would expect Jenkins to send emails only to those who have broken the build, i.e. those developers who have committed code between a successful build and the failed build. Now it seems that all our developers get sent an email for every failed build.
Any ideas?

Have you tried editable email notification, where you can configure for failure, unstable or any other kind of trigger.

Related

Jenkins e-mail notification only for first failing commit

For my Jenkins job I would like to have Jenkins send e-mails under two conditions:
The build was fine before, but now it fails.
The build failed before, but now it is fine.
I do not want it to send e-mails for any additional failing builds between (1) and (2).
I would have expected that having the setting "Send e-mail for every unstable build" unchecked would prevent just that, but I receive e-mail for every single failed build.
How can I achieve my desired behavior? Is this a bug in Jenkins (2.121.2) or the Mailer plugin (1.21)?
There is a better plugin for sending emails on certain conditions on Jenkins plugin site: https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin
Try finding Editable email in post-build actions or install it via Jenkins manage plugins options.
Below is a screenshot which is part of the Editable Email notification post-build task:

Bitbucket Server : Merge check - Minimum successful builds not enabling merge even after the condition is satisfied

I have configured Bitbucket Server to work with Jenkins by enabling a Webhook in Bitbucket with the Jenkins URL and the event being - Pull request approved. So I want a build on Jenkins to be triggered when a pull request is approved by the named reviewer.
The Jenkins job is configured to be triggered remotely using a token and that token is specified in the Bitbucket Webhook along with the Jenkins URL. This is working as expected. The Jenkins job is triggered automatically as soon as the pull request is approved by the reviewer.
But, I have also configured a merge check for the project . The merge check is enabled for minimum successful builds and the number of builds to be successful is configured to be 1. So, I expect the merge button to be enabled as the reviewer has approved the pull request and the Jenkins build has run (also success). But unfortunately, the merge button is not enabled even after all this. I also triggered a build manually on the same commit ( was success too ) but with no success on the merge button being enabled. Please help me out. Thanks.
I had the same problem and here are the steps of how I fixed it.
Use Bitbucket and not Git as the source code management. But, Bitbucket seems to be only avaiable when creating a Multibranch Pipeline.
Now, that you use Bitbucket, install plugin Bitbucket Branch Source Plugin
Bitbucket appears to get the result of the build from Bitbucket Branch Source plugin
The plugin requires some configuration, this webpage helped me a lot.
We had the same problem, if in your case you have at least one failed build before the succesfull one, then you will not be able to merge until you push a new code to the PR branch. This answer comes after discussing it with Bitbucket's support team.

Jenkins 2.3.5 Build Notification (Emailext, bitbucket build status notifier) Not Working

We recently rebuilt our Jenkins server and we are using Jenkins 2.3.5/JDK8/ubuntu 14.04/bitbucket cloud/hipchat cloud.
After we got the newly built Jenkins server running, everything worked except for the build result notification.
We used to get the bitbucket account that we used with Jenkins to comment on the build result, so we can receive it in the hipchat room, even without using hipchat notification plugin. Now, we have tried the emailext plugin, Bitbucket Build Status Notifier Plugin, but none of them worked. It seems that the plugin is all out of date in terms of configurations.
For emailext, it complains "An attempt to send an e-mail to empty list of recipients, ignored." But we put a number of email in the "Default Recipients". And all the SMTP settings are correct since we can receive testing message.
For Bitbucket Build Status Notifier Plugin, I followed here, but I couldn't find the "Bitbucket notify build status" in the job configure.
Any suggestions would be appreciated.
Use Extended Email notification plugin, set SMTP server in Jenkins global configuration

Bitbucket pull request builder plugin keeps triggering same commit build

I need to integrate Bitbucket with Jenkins. So that whenever a PR is opened it will trigger a build in Jenkins. Then commit status of the last commit in the PR will be updated as failed or success and this commit wont trigger the build again. (This works beautiful with Github but seems to be a nightmare for me with Bitbucket)
So far I did:
Installed Bitbucket pull request builder plugin.
Set everything up like its described in https://github.com/jenkinsci/bitbucket-pullrequest-builder-plugin#readme
User has write permissions to the repository (we added shh pub key to organization and its in the group that has write permissions)
Problems
Build is triggered over and over again for the same PR/commit
Commit status is not updated on bitbucket
Let me know if I can provide more information.
In my case, the Jenkins URL was set to http://jenkins:8080 and when such a URL was sent to BitBucket via their API, BitBucket returned the error "Invalid URL" (Look in Jenkins Logs: http://yourjenkins:8080/log/all) Which is not handled by the BitBucket Pull Request Builder plugin and thus kept continuously rebuilding all of our pull requests because it thought that build was not in progress. After setting Jenkins URL to http://jenkins.domain.tld:8080/ or http:///jenkins, the BitBucket API started accepting the URL and everything started to work.
But in your case it may be possible that some other error is the cause. You can check your Jenkins Error log to see the failure.
See the following issue: Build status notification fails with Enter a valid URL

Showing user details that has triggered the build on Jenkins Server while code is checked in into gitlab

I want to show user details of user who has triggered build on jenkns. I have integrated gitlab and jenkins and gitlab triggers the build on jenkins via web hook. We log in to gitlab through LDAP. Is there any way to show user details got from gitlab on Jenkins ???? Thanks in advance
At the moment, I don't believe this is possible. But it could be implemented.
In most cases where Jenkins jobs are triggered via Git webhook, the job itself is not triggered directly, but rather Jenkins is informed that for a given Git URI, there may have been changes.
Jenkins then polls Git for changes and, if something new was found, triggers a build of the jobs that use that repository. So at this point, various jobs just start, without receiving any special information about the webhook push that happened.
Also, a new build could have been triggered by multiple commits, from several different people, so it may not make sense to show a single person's name as being the one that triggered a build.
However, there are special implementations that understand the webhook payload format of different hosting services (e.g. GitHub, Bitbucket etc.).
Indeed, the GitLab Hook plugin looks like it does this: if you start a build via the /gitlab/build_now webhook endpoint, then on the build page, you'll see why the build started, e.g. "triggered by merge request feature -> develop" or "triggered by push on branch develop with 2 commits".
While it seems that part of the plugin does read an author's name from the payload (presumably for merge requests), this isn't currently shown on the build page.
So you could try implementing this or filing a feature request on the Jenkins plugin.
As a short term workaround, you can also look at the "Changes" page for each build. There you can see which commits were in that build, and the author names should be shown next to each one.
You may have to configure the "repository browser" under the Git section in the job configuration for this to work.

Resources