Email notification in jenkins based on a script output - email

I am stuck at a point where I run a perl script through jenkins and I want a conditional email notification to be sent.
For eg ..
if at the end of script the value of a certain variable is > 1 then send the email notification
else
dont send
Can anybody help me with this ? or knows a better way to do this ?

This can be solved using
Email-ext plug-in
https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin
And you can use the above link to view information regarding plugin
if i'm correct you want to send mails based on your build condition result.
you can use triggers for this in Editable email notification.
you can use post build step and pre build steps to trigger emails based on your conditions
you need to write a script for your requirement and place it in post & pre build steps.

I haven't any of this, however:
There is an Any Build Step plugin. Among other things, it allows post-build actions to be executed as build steps. In theory, this should allow you to execute "Editable Email Notification" post-build step as a build step. This is the biggest wildcard in this solution. Try this first. I don't know if the email notification will work properly when done before the Jenkins' "build cycle" of a job is complete.
Next, there is Conditional Build Step plugin. It allows you to execute a build step based on various conditions.
If you were able to trigger email in the middle of the build cycle with "Any Build Step" plugin, you should be able to wrap it with the "Conditional Build Step" plugin to be executed conditionally.
Let me know if this actually works

I was having a similar condition where I need to send out an email when jenkins build log has a string. Here is how I handled in the presend script of the jenkins job.
logger.println(build.getLog(50))
if (build.getLog(50).contains("NoChangesPresent")) {
cancel = true;
}
I am trying to get the last 50 lines of build log and search through it to see if there is a string present. If it is present then I am setting cancel to true which would stop triggering the email from jenkins.
Hope this helps.

I like siri's answer. There is one think missing.
logger.println(build.getLog(50)) if
(build.getLog(50).toString().contains("NoChangesPresent")) { cancel = true; }
It doesn't appear that contains will function without converting it first to a string. Good luck!

Related

Azure Devops Boards - can we block task from done if there isn't any test attatched?

We are trying to implement a new method for our QA team.
I have looked around the setting but couldn't find an answer:
Is it possible to prevent them from dragging the task to 'Done' if they haven't added a test case into it?
On the same logic - can we block the 'committed' column from them if they haven't added a bug to the task?
Thank you.
There is currently no build-in feature to help you achieve this directly.
Here is a work around for your demand:
Create a new filed named "TestCaseLinked"
Every time a Test Case is linked to the task WIT, you need to manually put a value into this field. And use the WIT rule to check the value when changing the WIT status to "Done"

Course completion report is not working properly it showing the wrong output

i am trying to implement the course completion status block in my moodle to check this i made a student account in that status is showing pending and also other status is not working correctly i give the course completion setting and activity completion setting. And if i click on "More Details" this page is opening (picture 2) in which it also showing incomplete and complete the quiz and pass also still it showing incomplete.
And after this i check in admin from course report so this also reflecting there, in (picture 3) self completion and course complete is unmarked.
I need this to check the student is complete the task properly so i can provide the certificate to him "not custom certificate".
So Anyone could please suggest something?
First of all you have to check that your cron file is working or not for that go to administration>server>scheduled task in that check for the completion regular task is working if not then first work for you cron then it will automatically work.
And your self completion is still not responding after that this is because you didn't add the self completion so add this block and manually complete the course and then it will properly.
For cron i suggest you only go for moodle docs only and then implement it.

Jenkins send mail based on build parameters with attachments

I want to send mail with attachment to recipients in post build task if value of Env parameter is "FAILEDBUILD". This value I am providing at the start of the build in "build with parameter" window.
One thing what you can do is, in Build Section of the Jenkins Job, you can configure something like below.
Then in Post Build Action, using the below plugin will help you in doing that.
Try with the text finder plugin , you can set the build status depending on a single keyword or regular expresion looking on the console output.

Sending one single email for multiple builders

I am setting up a build environment with a unique master buildbot and multiple buildslaves. I have multiple builders which will run on the available slaves. The builders can be triggered on-force or scheduled to run as nightly builds or can be scheduled to run when some changes are detected.
I have setup a MailNotifier to send the results/status of the builds. This MailNotifier will send one email for each of the builder. What I want to do now is to send a single email for multiple builders. For e.g. all the nightly builders after successfully building, trigger some function in master buildbot which will trigger the buildbot to send a single email which includes the results of all the nightly builders.
I would like to know whether something like this is possible and whether buildbot provides support to send a single email for multiple builders. If not any pointer how to accomplish this ??
Thanks in advance !!
You are looking for buildSetSummary parameter to MailNotifier: if you set this parameter to True, it will send a single e-mail listing statuses of all completed builds.
More information: Buildbot Manual
It's been quite a while since you asked this but just in case you still need an answer, look at the settings for buildbot's MailNotifier. The default behaviour is to send an e-mail for each builder, so you have to specify which ones you're interested in using the builders argument (scroll down the page):
builders (list of strings). A list of builder names for which mail
should be sent. Defaults to None (send mail for all builds). Use
either builders or categories, but not both.
Hope this is what you were looking for!
Create a TriggerableScheduler with all your builders in builderNames. Then, create a "super" builder with the following 2 steps:
trigger the new TriggerableScheduler with waitForFinish=True
send the email

Why does my CRM workflow steps run individually but not when two steps exist?

I have created a custom workflow activity that copies attachments from a case to an email, both supplied as Lookup parameters. I installed the workflow assembly, created a case with attachments and an email. I then used the workflow design to create a new workflow with one step that runs my custom activity. The attachments copied nicely.
The first use of the custom workflow assembly is to create the email before doing the copying the attachments. I therefore created a new workflow that created an email using details from a case. I set this up as a manual workflow as this it what the end user (CRM consultant) will be doing. I ran that workflow and an email was created as expected.
I then modified the second workflow to add a second step. The second step copies the attachments from the current case to the created email. When I ran the workflow, it failed on step 1.
I modified the workflow so that the email from step 1 was not used in step 2. Instead, I used an existing email as per my very first test. This means that the two steps when executed individually work and if they ran concurrently they should work because there is no link between them. However, when I ran the workflow, it failed on step 1.
Can anyone suggest why this may be happening?
I found the answer so thought I would post it here. I had a class in use that was not marked with the [Serializable] attribute. Once the attribute was added, the problem went away.