# Send full buildLog in post step

**URL:** <https://community.jenkins.io/t/send-full-buildlog-in-post-step/11179>\
**Category:** Ask a question\
**Tags:** logging\
**Created:** [December 8, 2023, 1:39pm UTC](https://community.jenkins.io/t/send-full-buildlog-in-post-step/11179 "2023-12-08T13:39:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheerbuzz](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@cheerbuzz](https://community.jenkins.io/u/cheerbuzz)\
**Post date:** [December 8, 2023, 1:39pm UTC](https://community.jenkins.io/t/send-full-buildlog-in-post-step/11179/1 "2023-12-08T13:39:51Z")

</div>

So i want to send a Notificaton with the build log attached in the post step of a pipeline but sadly the output of the buildLog only goes as far as my function call is.

retrieve (currentBuild.rawBuild.logFile.text) → send notification.

This means that error messages will never show up.  
Is it possible to send the full log from within the pipeline?

Edit: Also while on that topic maybe someone knows how to get a good error message in a declarative Pipeline. I know you can catch the error in your script enclosures but that means you lose out on all the errors afaik, unless you do follow the exception chain and throw it again, but then you also only throw the last one again without the real cause attached to it. Which then in the jenkins instance shows less detailed errors i assume.

Jenkins setup: Jenkins 2.426.1 only recommended plugins installed

---

<div class="post-metadata">

**Author:** ![samrocketman](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/samrocketman/32/4631_2.png) [@samrocketman](https://community.jenkins.io/u/samrocketman)\
**Post date:** [December 9, 2023, 11:46am UTC](https://community.jenkins.io/t/send-full-buildlog-in-post-step/11179/2 "2023-12-09T11:46:19Z")

</div>

A couple of points:

- Logs can be large (hundreds of MBs or more). Jenkins doesn’t compress logs so you should
- Due to size you shouldn’t email as an attachment. Instead, host your logs somewhere and email a link to them.
- You likely can’t accomplish this without a plugin.

Write a class extending `RunListener<Run<?, ?>>` and `@Override` method `public void onCompleted(Run<?, ?> build, TaskListener listener)`

onCompleted is called after the build completes allowing you perform post run activities. This will occur for all jobs in Jenkins globally. Filter for job types you want to support like `WorkflowRun`.

Classes

- hudson.model.listeners.RunListener
- hudson.model.Run
- hudson.model.TaskListener
- org.jenkinsci.plugins.workflow.job.WorkflowRun

This is probably a bit more advanced than you’d want (requires plugin writing and compiling) but this is what I ended up doing for archiving compressed logs.

---

<div class="post-metadata">

**Author:** ![cheerbuzz](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@cheerbuzz](https://community.jenkins.io/u/cheerbuzz)\
**Post date:** [December 11, 2023, 8:57am UTC](https://community.jenkins.io/t/send-full-buildlog-in-post-step/11179/3 "2023-12-11T08:57:01Z")

</div>

Could it be as simple as overriding this class in my jenkinsfile or a library script? Or do i literally have to learn how to write a jenkins plugin
