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
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
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
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.
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