You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-12-01 23:02:43 +02:00
3.0 KiB
3.0 KiB
mailSendNotification
Description
Sends notifications to all potential culprits of a current or previous build failure plus 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
Prerequsites
none
Example
Usage of pipeline step:
mailSendNotification script: this
Parameters
| parameter | mandatory | default | possible values |
|---|---|---|---|
| script | yes | ||
| buildResult | no | ||
| gitCommitId | no | script.commonPipelineEnvironment.getGitCommitId() |
|
| gitSshKeyCredentialsId | no | `` | |
| gitUrl | no | ||
| notificationAttachment | no | true |
|
| notificationRecipients | no | ||
| notifyCulprits | no | true |
|
| numLogLinesInBody | no | 100 |
|
| projectName | no | ||
| wrapInNode | no | false |
Details
scriptdefines the global script environment of the Jenkinsfile run. Typicallythisis passed to this parameter. This allows the function to access thecommonPipelineEnvironmentfor storing the measured duration.buildResultmay be used to overrule the build result coming fromcurrentBuild.result. This is for example used in the steppipelineRestartStepsgitCommitIddefines a dedicated git commitId for culprit retrieval.gitUrlandgitCommitIdare used to retrieve culprit information.gitSshKeyCredentialsIdonly required if your git repository is protected. It defines the credentialsId for the git ssh credentials.notificationAttachmentdefines if the console log file should be attached to the notification mail.notificationRecipientsdefines the fixed list of recipient that always get the notification. In case you want to send the notification to the culprits only set it to an empty string''.
!!! note
Multiple recipients need to be separated with the space character.
In case you do not want to have any fixed recipients of the notifications leave the property empty.
notifyCulpritsdefines if potential culprits should receive an email.numLogLinesInBodydefines the number of log lines (=last lines of the log) which are included into the body of the notification email.projectNamemay be used to specify a different name in the email subject.wrapInNodeneeds to be set totrueif step is used outside of a node context, e.g. post actions in a declarative pipeline script.
Step configuration
We recommend to define values of step parameters via config.yml file.
In following sections the configuration is possible:
| parameter | general | step | stage |
|---|---|---|---|
| script | |||
| buildResult | X | X | |
| gitCommitId | X | X | |
| gitSshKeyCredentialsId | X | X | X |
| gitUrl | X | X | |
| notificationAttachment | X | X | |
| notificationRecipients | X | X | |
| notifyCulprits | X | X | |
| numLogLinesInBody | X | X | |
| projectName | X | X | |
| wrapInNode | X | X |
Side effects
none
Exceptions
none