Jenkins notification email - jenkins

I have a jenkins pipeline job and pipeline in groovy script. It sends out email
notification every time a job starts and finishes. Now i was told to include the reason for build(ex: git comments, who initiated the job etc) as part of email notification. I am not able to decide how to achieve this.

You can call the API url
http://"JENKINS_URL"/job/"JOB_NAME"/"JOB_NUMBER"/api/xml
or
http://"JENKINS_URL"/job/"JOB_NAME"/"JOB_NUMBER"/api/json
for JSON output.
then all you have to do is get the "shortDescription" from there which is the build trigger e.g. Triggered by GitLab Merge Request #21: "branch name" => master

Related

Jenkins: no email to recipients (integration with GitLab)

I'm using Jenkins (with Email Extension plugin ... ), integrated with GitLab.
For my job in my post build actions configuration, I see this (note that the recipients list is empty ...)
When the job fails I see this in the console output
15:29:50 New run name is '#25'
15:29:51 Sending e-mails to: name1.surname1#mydomain.com name2.surname2#mydomain.com
name3.surname3#mydomain.com
and emails are sent.
Where are these names found/are coming?
Any suggestion will be appreciated.
Your E-mail Notification is configured with the Send separate e-mails to individuals who broke the build option enabled. This makes the Mailer Plugin send a notification to each e-mail address involved in committing Changes for the build in case the build failed.
Changes and their authors are shown at each job page.
For example, there are 4 Git commits from 4 different authors (identified by email). Those commits gets pushed to the Git server and Jenkins job gets started. The job picks all those new commits and fails. The plugin then picks all distinct emails from the commits and sends an email to each commit author assuming at least one of them broke the build.

Jenkins Email notification for multiple builds

I need suggestion for Jenkins project (multi-conf or pipeline) and plugins that will fit my work.
I have 10 "flavors" of the product, so I must build 10 times every time I commit to the repository (all in the same workspace, run in sequentially). Today I have 10 jobs (freestyle) and a "master" job that trigger the rest. I tried to add Email notification (using Email Extension Plugin) but I want only one Email report for all the builds, not 10 Emails.
I understand that I should change to one multi-configuration project or one pipeline project that will handle all the builds, so it will be easier to trigger only one Email, but what is the best practice to get only one Email report on multiple builds?
This is the exact scenario which we can achieve using Pipeline job(Jenkinsfile) from which you can trigger all those freeStyle build-jobs in parallel and collect the build-url and build-status of those and store in some file, then use the email plugin in the post-build task to send the status of your complete flow.
You can use the following link to find how to access build variable post calling that inside your pipeline.
How to I get the url of build triggered with build step on Jenkins?

Can Jenkins send notification mail when somebody changes the Configure in the job?

Can Jenkins send notification mail when somebody changes the Configure(e.g String Parameter, choice Parameter, Execute shell scripts or other stuff) in the job?
It sounds partially supported through the Mail Watcher plugin:
https://wiki.jenkins.io/display/JENKINS/Mail+Watcher+Plugin
https://issues.jenkins-ci.org/browse/JENKINS-3032
Limitation is that you are notified about a changement, but you won't know what has been changed.

Retrieve console log from a nested job in jenkins

I have a Matrix job (Job A) with that call build sub job (B) using Jenkins Parameterized Trigger plugin.
In the Parent Job (Mtrix) i use Editable Email Notification to trigger each configuration.
I want to get 15 lines from child job (B) build log for each configuration to add it in the email (if the build fails).
How can I do such thing ?
This plugin allows you to configure every aspect of email notifications. You can customize when an email is sent, who should receive it, and what the email says.
here is the link : https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin

Jenkins Email-ext plugin not sending notification when new branch fails for first time

Steps to reproduce my problem:
Using GIT for SCM and Jenkins is set up to trigger build on SCM change
Master branch is building fine and all tests are passing
Create new branch from master
Break something so build fails and push to the new branch
Build is triggered in Jenkins by SCM change
Expected result is that email-ext plugin sends notification of build failure to the person who first pushed to the new branch.
But actually no e-mail is sent and the log says:
Email was triggered for: Failure - Any
Sending email for trigger: Failure - Any
An attempt to send an e-mail to empty list of recipients, ignored.
Finished: FAILURE
The "Failure - Any" trigger has both Developers and Culprits set under "Send To".
When a second commit is made to the new branch by the same person, the trigger works fine - it finds the e-mail address of the culprit and sends the e-mail.
Using Email-ext version 2.38.1, Jenkins 1.575.
The triggers I have configured:
Screenshot from the first failing build after creating a new branch is below. (Branch is immediately broken)
I think the problem might be that it says "No changes", although it is triggered by a SCM change.
If it is changed with a second commit, it will show that commit under "Changes" and then it knows who to send the e-mail to.
Any way to get the plugin to send an e-mail to the one who creates the broken branch? Thank you.

Resources