4

How is it possible to use Metadata in on_success/on_failure? For example, to send emails via https://github.com/pivotal-cf/email-resource?

I haven't found a way, as I can't change content of files where email resources reside (subject/body), as the metadata is not available to tasks.

And yep, that might be a duplicate for Concourse CI and Build number

But still my question IMHO is a valid use case for notifications.

Max Romanovsky
  • 2,824
  • 5
  • 30
  • 37

1 Answers1

2

The metadata you are referring to, I assume, is the environment variables provided to resources, not tasks.

This can be used with the slack resource to provide information about what build failed.

For example:

on_failure:
    put: slack-alert
    params:
      text: |
        The `science` pipeline has failed. Please resolve any issues and ensure the pipeline lock was released. Check it out at:
        $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME

The email resource, you're referencing has an open PR to support these environment variables. I'd discuss your need for that feature there.

ajsharma
  • 1,188
  • 1
  • 10
  • 17
jtarchie
  • 251
  • 2
  • 13
  • Thanks for the answer! I've subscribed to that PR on Github. – Max Romanovsky Jul 13 '17 at 08:09
  • Is this really the best way to get the URL for a build on Concourse CI? They don't expose a _single_ env var for this, such as `BUILD_URL` with Jenkins? – AutonomousApps Aug 20 '19 at 22:19
  • @AutonomousApps, correct, they deliberately hide the information to stop people from doing things they consider bad practice, like using concourse job identifiers for versioning. – Charles Duffy Oct 06 '22 at 15:36
  • what about when using other resources? Does the resource have to support this specifically? – trainoasis Dec 09 '22 at 16:25