mailSendNotification¶
Description¶
Sends notifications to all potential culprits of a current or previous build failure and to fixed list of recipients. It will attach the current build log to the email.
Notifications are sent in following cases:
- current build failed or is unstable
- current build is successful and previous build failed or was unstable
Prerequisites¶
none
Example¶
Usage of pipeline step:
mailSendNotification script: this
Parameters¶
| name | mandatory | default | possible values |
|---|---|---|---|
buildResult |
no | ||
gitCommitId |
no | ||
gitSshKeyCredentialsId |
no | `` | Jenkins credentials id |
gitUrl |
no | ||
notificationAttachment |
no | true |
true, false |
notificationRecipients |
no | ||
notifyCulprits |
no | true |
true, false |
numLogLinesInBody |
no | 100 |
|
projectName |
no | ||
script |
yes | ||
wrapInNode |
no | false |
true, false |
buildResult- Set the build result used to determine the mail template. defaultcurrentBuild.resultgitCommitId- Only ifnotifyCulpritsis set: Defines a dedicated git commitId for culprit retrieval. defaultcommonPipelineEnvironment.getGitCommitId()gitSshKeyCredentialsId- Only ifnotifyCulpritsis set: Credentials if the repository is protected.gitUrl- Only ifnotifyCulpritsis set: Repository url used to retrieve culprit information. defaultcommonPipelineEnvironment.getGitSshUrl()notificationAttachment- defines if the console log file should be attached to the notification mail.notificationRecipients- A space-separated list of recipients that always get the notification.notifyCulprits- Notify all committers since the last successful build.numLogLinesInBody- Number of log line which are included in the email body.projectName- The project name used in the email subject. defaultcurrentBuild.fullProjectNamescript- The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with thethisparameter, as inscript: this. This allows the function to access thecommonPipelineEnvironmentfor retrieving, e.g. configuration parameters.wrapInNode- Needs to be set totrueif step is used outside of a node context, e.g. post actions in a declarative pipeline script. defaultfalse
Step configuration¶
We recommend to define values of step parameters via config.yml file.
In following sections of the config.yml the configuration is possible:
| parameter | general | step/stage |
|---|---|---|
buildResult |
X | |
gitCommitId |
X | |
gitSshKeyCredentialsId |
X | X |
gitUrl |
X | |
notificationAttachment |
X | |
notificationRecipients |
X | |
notifyCulprits |
X | |
numLogLinesInBody |
X | |
projectName |
X | |
script |
||
wrapInNode |
X |
Dependencies¶
The step depends on the following Jenkins plugins
- email-ext
- pipeline-utility-steps
- ssh-agent
- workflow-basic-steps
- workflow-cps-global-lib
- workflow-durable-task-step
Transitive dependencies are omitted.
The list might be incomplete.
Consider using the ppiper/jenkins-master docker image. This images comes with preinstalled plugins.
Side effects¶
none
Exceptions¶
none