We use Jenkins as our ci server, and we run integration test on firefox on xvfb. Sometime, we receive the email about test failure, caused by xvfb starting failed.
So we want to ignore sending email by this case. As we know, the email-ext plugin can help us. we should write pre-send scripts, but we don’t know how to write them.
How do I write a script to cancel sending email when failure output message contains a specified error message?
Solution:
My groovy script in email-ext plugin pre-send-script is:
123456
try {
def logFilePath = build.getLogFile().getPath();
String logContent = new File(logFilePath).text;
if (logContent.find(/Xvfb failed to start/)) cancel=true;
} catch (all) {
}
test-email - Build # 9 - Successful:
Check console output at http://jenkins.cb-apac.com/job/test-email/9/ to view the results.
Changes:
Wei Luo: f87b103da4817cbcf1a4ce17ed5bf9687146bfdf
- app/jobs2/checkparams_check.rb
- config/resque_schedule.yml
- app/jobs2/watch_dog.rb
-- copy jobs to resque.
This is arguments description
123456789101112131415161718192021222324
${CHANGES}
Displays the changes since the last build.
showDependencies
If true, changes to projects this build depends on are shown. Defaults to false
showPaths
If true, the paths, modifued by a commit are shown. Defaults to false
format
For each commit listed, a string containing %X, where %x is one of:
%a
author
%d
date
%m
message
%p
path
%r
revision
Not all revision systems support %d and %r. If specified showPaths argument is ignored. Defaults to "[%a] %m\\n"
pathFormat
A string containing %p to indicate how to print paths. Defaults to "\\t%p\\n"