${build.result} in Editable Email Notification Default Content - jenkins

I am trying to print ${build.result} in Editable Email Notification Default Content.
I receive the email with the content as ${build.result} instead of printing the actual result "SUCCESS".
Can any one suggest here if i am missing something.

On my last project we used this template and it worked perfectly well.
The jelly for this template is here and includes the build result and the appropriate Jenkins Orb icon.

Related

Sending robot framework log file as email content via Jenkins is not getting displayed

I have created a Jenkins job to execute robot framework. The results[log.html and report.html] of the Jenkins are getting displayed properly.
Now I am using the email-ext plugin to send the log file as email content to the specified group of users, but the received email doesn't display the content and shows error as "Opening Robot Framework log failed" in the email.
I have set the email-ext plugin as follows:
I wish to send the robot results as email content, not as an attachment, I have tried various methods like Linux, shell scripting etc, but still, it doesn't work. How can the log.html email content can be sent to the email body?
You will not be able to just put the entire content of the robot log.html in an email because it contains javascript.
I've been looking into this the last few days as well and have come to see that using a groovy based template using the jenkins Email-ext plugin is the way to go. Googling for 'jenkins robot framework email template' shows a few hits and one that I'm planning to try and then modify to my liking was this one:
https://github.com/vladwa/robot-email-template
From this I found that we don't have access to all of the test info built in, so I wrote up some modifications to load the robot output.xml as an artifact to then be able to inject any data in that file into the html email report. Here's the gist of that:
https://gist.github.com/harbdog/070f0be66ebae343d6d11e57a6c6fc08
Here's what it looks like for example:
You have to configure publish robot framework test result <post build> and then use {ROBOT_REPORTLINK} in email content section

Not able to access custom parameters passed to the jenkins build script

I want to add some parameters from the web hooks into the mail sent from the Jenkins. I tried solutions provided in StackOverflow and elsewhere. No success yet.
I have the following in place:
Checked This is a parameterized build
The build script looks like http://JENKINS_URL/job/android02/buildWithParameters?token=<My Token>&PARAM=<My Custom Params>
In the mail content, I try to access the custom parameters by ${PARAM}, $PARAM.
In the mail, however, I'm not getting the values I'm setting. If I set default values for PARAM, it is correctly displayed in the mail I receive. I tried http://JENKINS_URL/job/android02/build?token=<My Token>&PARAM=<My Custom Params> URL as well thinking just in case if it works. The mail is sent as Editable email Notification config.
Basically, everything is working except that I'm not able to access the custom parameters I have passed via Trigger builds remotely option.
Edit1:
If I keep a default value, say, test for the parameter, PARAM, in the mail received, I can see test displayed. But I need to get the value I'm passing in the build script.
From the "tool tip" that you get when you click on the question mark next to "":
${ENV,var="VARIABLENAME"}
Expands to an environment variable (specified here as VARIABLENAME) from the build environment. Note that this does not include any variables set by the build scripts themselves, only those set by Jenkins and other plugins.
So, use ${ENV,var="PARAM"}.

How can I get the SVN log entry in Jenkins when sending email

I'm trying to create an automated build at work using Jenkins. We're using SVN for version control. When a build is successful I would like to send an email to my team saying... Person X has committed the following changes.
How can I include the committers name and the last SVN log entry in the body of the email?
I'm using the Jenking email-ext plugin.
Thanks!
Subject line:
To display the committer(s) of the last build, you can put the following into the subject line anywhere you want. Do note that if multiple people have committed since the last build, multiple names will be shown, hence the (space) in "%a ".
${CHANGES, format="%a "}has/have committed the following changes
Or to display a list of culprits that broke the build
Build broken by ${CHANGES_SINCE_LAST_SUCCESS, reverse=true, format="%c", changesFormat="%a "}
Unfortunately, if a culprit's name appears several times in commit messages, it will appear several times in the subject too.
SVN log in the email
To get the SVN log into the email, I use the following:
${CHANGES_SINCE_LAST_SUCCESS, reverse=true, format="<b>Changes for Build #%n</b><br>%c<br>", changesFormat="<br>[<a href='${JENKINS_URL}/user/%a/builds'>%a</a>] - (%r) %p<br> %m<br>"}
This was all pulled together from the Content Token Reference on-page help with lots of trial and error. Scroll to the bottom of your email-ext configuration, and click the ? icon in-line with Content Token Reference text (it may take a while to load)
Produces output similar to:
Changes for Build #123
[commiter_name] - (1234567) /svn/path/to/changed.files
Commit message here

Jenkins sending attachments with email plugin

I'm trying to attach a file when a test fails in Jenkins.
I'm using the email extension plugin as a means of trying to achieve this but I'm stumped by the syntax.
If I simply put "index.php" (without quotation marks) in the attachment field it will send out the attachment correctly.
If I try and go further into the workspace e.g."myfolder/myfile.php" (without quotation marks) the email wont send. I've tried a number of variants, using wildcards and trying to target files specifically but with no luck.
I have of course looked here http://ant.apache.org/manual/Types/fileset.html but nothing seems to work.
Try **/myfile.php
This will look for myfile.php regardless of the directory structure

Jenkins Email-ext plugin - tokens

Hi I'm using Jenkins Email-ext plugin.
Where can I find a list of all the things I can refer to in the html content of the email?
For instance: I recently found out that you can put parameters values inside the mail using:
${ENV,var="variable_name"}
But say that I want to get build log or build number or build status (passed fail).
Do you know if there is a document listing all data that is referable in this plugin.
Thanks!!
On job configurations page:
Check 'Editable Email Notification' box -> find 'Content Token Reference' (it's between 'Attachments' and 'Trigger for matrix projects') -> Click on ? to the right side of it.

Resources