Max Romanovsky
Max Romanovsky

Reputation: 2894

Concourse CI: Use Metadata (Build number, URL etc) in on_success/on_failure

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.

Upvotes: 4

Views: 4641

Answers (1)

jtarchie
jtarchie

Reputation: 251

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.

Upvotes: 2

Related Questions