How to attach files to Jenkins Pipeline notification
Asked Answered
C

1

17

I am trying in a pipeline to attach files to my notification mails.

How can I do that? An example would be nice.

Capitate answered 2/1, 2017 at 6:55 Comment(0)
F
35

email-ext uses Ant File Syntax

As for example usage:

emailext attachmentsPattern: '**/report.html', body: 'Find attachments', subject: 'test', to: '[email protected]'
Fluoroscope answered 5/1, 2017 at 14:24 Comment(11)
attachementPattern does not accept all file path ?? for example ${workspace}/file.xmlCroissant
works as expected. another thing that is important in this context, is another boolean key/value 'attachLog: true' . not to be confused (as i did...) - the boolean is only for sending the build log of jenkins itself, rather than 'attachmentsPattern' which allow to customize based on Ant patternsMidterm
def file_name = "file.txt" and calling attachmentsPattern: "${file_name}". its unable to call that file. please suggestLourdeslourie
if there are two files then?Diamagnet
Hi @Khan, would you be able to write a pattern that matches both of them?Fluoroscope
For example the all files in a folder reports, so can I do like **/reports/*Diamagnet
The first start should be doubled unless you can provide a full path (then it matches all report directories in your working directory tree). Then you need a star at the end to pick all the files in the matched directories. EDIT: yeah, just like you edited.Fluoroscope
Also you can add specific more than one file: attachmentsPattern: 'report.html, test.html,....'Enfleurage
I am getting ERROR: Error accessing files to attach: Expecting Ant GLOB pattern, but saw '/tmp/output.text' ...... I want to attach file /tmp/output.textWanting
@AshishKarpe this pattern is relative to your workspace, you would need to do ../ as many times to get to the /, and then have the rest of it, for example ../../../../tmp/output.textFluoroscope
@Fluoroscope I tried to cp /tmp/output.text $WORKSPACE/ but my workspace is getting cleaned so getting errorWanting

© 2022 - 2024 — McMap. All rights reserved.