How to attach files to Jenkins Pipeline notification

26,206

email-ext uses Ant File Syntax

As for example usage:

emailext attachmentsPattern: '**/report.html', body: 'Find attachments', subject: 'test', to: '[email protected]'
Share:
26,206
eran meiri
Author by

eran meiri

Updated on August 09, 2020

Comments

  • eran meiri
    eran meiri over 3 years

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

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

  • sirineBEJI
    sirineBEJI almost 6 years
    attachementPattern does not accept all file path ?? for example ${workspace}/file.xml
  • chenchuk
    chenchuk almost 5 years
    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 patterns
  • Suraj Nerati
    Suraj Nerati over 4 years
    def file_name = "file.txt" and calling attachmentsPattern: "${file_name}". its unable to call that file. please suggest
  • Khan
    Khan about 3 years
    if there are two files then?
  • hakamairi
    hakamairi about 3 years
    Hi @Khan, would you be able to write a pattern that matches both of them?
  • Khan
    Khan about 3 years
    For example the all files in a folder reports, so can I do like **/reports/*
  • hakamairi
    hakamairi about 3 years
    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.
  • Yakir GIladi Edry
    Yakir GIladi Edry almost 3 years
    Also you can add specific more than one file: attachmentsPattern: 'report.html, test.html,....'