Meta-data in notification message text

There’s a value that gets calculated mid-way through my build (during the 4th step, to be precise). It’s just a simple short string. I’d like to include that value in the message text of a Slack notification that gets sent when the build finishes.

The value was previously only saved as an artifact (a text file), using buildkite-agent artifact upload "foo_mode.txt" . I figured it wouldn’t be possible to grab the contents of an artifact for the notification text, so I’ve made it also get saved as meta-data, using buildkite-agent meta-data set “foo-mode” “${FOO_MODE}” .

Currently I’m trying this in my build steps yaml (just after steps:):

  - slack:
        - "#mychannel"
      message: "FOO_MODE: ${build.meta_data['foo-mode']}"

But that just results in the message text FOO_MODE: (i.e. no value).

Is there a way to insert a meta-data value in notification message text, as I’m trying to do?

If not, can anyone suggest another way that I can get this value coming through in notification message text?

Hi @jaza!

Env interpolation will only work there if the env itself is already set; but it won’t be set if the env: is in the same YAML as the notification. I’m not sure there’s a way for the meta-data interpolation to work there :confused:

Yes, that’s what I thought, that a given value has to be passed as an environment variable.

So I guess a better question for me to ask might be: is there any way that a value calculated during the build (i.e. it’s not available at the very start of the build) can be set as an environment variable, which would then be available for interpolation in the notification yaml?