Email by on_error step hook

Hello!
I have latest concourse version 5.4.0, and try to use new feature on_error

The goal is to get error message from job and send it to email.

For test on_error step hook i create pipeline:

groups: []
resources:
- name: resource-gist
  type: git
  source:
    branch: master
    skip_ssl_verification: true
    uri: https://github.com/some_repository
- name: send-an-email
  type: email
  source:
    from: from@email.com
    smtp:
      anonymous: true
      host: some.smtp.server
      port: "25"
      skip_ssl_validation: true
    to:
    - test@email.com
resource_types:
- name: email
  type: docker-image
  source:
    repository: pcfseceng/email-resource
    tag: latest
jobs:
- name: job-error
  public: true
  plan:
  - aggregate:
    - get: resource-gist
      trigger: true
      version: every
  - aggregate:
    - task: task-errot
      config:
        platform: linux
        image_resource:
          type: docker-image
          source:
            repository: ubuntu
        run:
          path: source-code
          args:
          - pwd
      on_error:
        do:
        - put: send-an-email
          params:
            body_text: 'Build error in concourse: ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME}'
            subject_text: 'Build error in concourse: ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME}'
      on_failure:
        do:
        - put: send-an-email
          params:
            body_text: 'Build failure in concourse: ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME}'
            subject_text: 'Build failure in concourse: ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME}'
      on_success:
        do:
        - put: send-an-email
          params:
            body_text: 'Build success in concourse: ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME}'
            subject_text: 'Build success in concourse: ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME}'

on_error step hook is working and i receive message:
Build error in concourse: test_alerting/job-error/5

And have output in concourse:

Question is how i can get this error message and send it by email?
Help please!!!

I don’t think you can. I’m not aware of a way to access error output from a previous step. You could likely construct the url of the failed job as your email body though. This would make it easier to check what the error was.