This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Emailing Results
Jeremy Poulin edited this page Nov 29, 2018
·
3 revisions
Sometimes, an effective way of monitoring the results of a test involve emailing those results upon test completion. You can find an example of how this can be done in the Ansible Engine Test, and I will summarize the essentials below.
string(
defaultValue: '',
description: 'Semi-colon delimited list of email notification recipients.',
name: 'EMAIL_SUBSCRIBERS'
)
First, you want to build strings that will encapsulate the subject and body of your email. Once that is done, you can send an email by simply calling the emailext build step with the parameters listed below.
def emailBody = "Results for ${env.JOB_NAME} - Build #${currentBuild.number}\n\nResult: ${currentBuild.currentResult}\nURL: $BUILD_URL"
if (errorMessages) emailBody += "\nErrors: " + errorMessages
emailext(
subject: "${env.JOB_NAME} - Build #${currentBuild.number} - ${currentBuild.currentResult}",
body: emailBody,
from: 'multiarch-qe-jenkins',
replyTo: 'multiarch-qe',
to: "${params.EMAIL_SUBSCRIBERS}",
attachmentsPattern: 'artifacts/tests/**/**/artifacts/**/*.*'
)
The subject of your email.
The body of your email.
The sender of the email as it appears when received.
The email address that recipients should direct their responses to.
The list of recipients.
Specifies the path to the files that should be attached. Uses ant-glob syntax.