2

I'm trying to access an archived post build artifact, extract, reformat the data and send it out in an editable email notification.

However, I'm struggling to find a way to access the artifact in the pre-send script.

Any suggestions on what I can do?

Javier C.
  • 7,859
  • 5
  • 41
  • 53
Andrew
  • 21
  • 2

1 Answers1

2

If you are using freestyle projects, you can set a file as the mail's content in your presend script:

def reportPath = build.getWorkspace().child("mail.txt"); 
msg.setContent(reportPath.readToString(), "text/plain");

In declarative pipelines:

emailext (
    body: readFile('mail.txt')
)

You can add anything to that .txt file; for example, I include the changed file names to the mail (using SVN), and the error log:

echo Build successful, changeset: > mail.txt && svn diff -r COMMMITTED:PREV >> mail.txt

echo Build failed, changeset: > mail.txt && svn diff -r COMMMITTED:PREV >> mail.txt && echo Errors: >> mail.txt && cat error.log >> mail.txt
Thomas Sauvajon
  • 1,660
  • 2
  • 13
  • 26