I've built an ETL structure in Pentaho for a DW, but, we use an unstable OLTP database as source, so sometimes an error can happen in the jobs (because the database if off).
I need to create an job in Pentaho that sends an email if the job / transformation didn't work and fails, how can I do that?
Depends on how specific the error handling needs to be. Most of the time I handle my database connection in a seperate transformation. For this I use a generic upsert mechanism. Inside of the transformation I have different abort steps which are connected via error-hops to the different database interaction steps. If any database connection for some reason is failing, they will abort the transformation and log the issue.
Now, the important thing to understand here, is that these different error steps do NOT report the transformation as an error in the parent flow, since the system sees the error as handled and thus the remainder of the parent flow will just continu after a log is made of the error.
To have the parent flow stopped and aborted you have to set the error in the transformation on error mode (see pic) this way also the transformation itself in the parent flow will be mentioned as a defect. And then this can be handled as an error on a higher level which you can send by error-hop to an email step, or to a generic transformation which send email based on an error message (see pic2).
edit: typos