GUIDE

The road ahead will be long and our climb will be steep

Jenkins Email Notificaiton

| Comments

Email notification with Email-ext plug-in:

  • pre-send scripts

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:

1
2
3
4
5
6
try {
    def logFilePath = build.getLogFile().getPath();
    String logContent = new File(logFilePath).text;
    if (logContent.find(/Xvfb failed to start/)) cancel=true;
} catch (all) {
}

That resolve my problem.

  • CHANGES Token, follow this

Config email notification in specified job, change the content like below:

1
2
3
4
5
<pre>$PROJECT_DEFAULT_CONTENT</pre>
<pre>
Changes:
${CHANGES, showPaths=true, format="%a: %r %p \n-- %m", pathFormat="\n\t- %p"}
</pre>

Then I will receive this format email:

1
2
3
4
5
6
7
8
9
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
${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"

TO BE CONTINUE

Comments