Pass meta-data to a triggered pipeline

I have a pipeline with steps that look like

- block: "block 1"
    key: block-1
    fields:
      - text: "Please enter the value"
        key: "value1"
  - trigger: "another-pipeline"
    build:
      message: "Use $(buildkite-agent meta-data get 'value1') from #${BUILDKITE_BUILD_NUMBER}"
      branch: "some_branch"
      env:
        VALUE_1: "$(buildkite-agent meta-data get 'value1')"
    depends_on: block-1

When I run the pipeline, the meta-data is not retrieved before triggering the other pipeline. Instead, the whole $(buildkite-agent meta-data get 'value1') is passed to the triggered pipeline, and I get a key not found error because value1 does not exist in the triggered pipeline.

How can I get the meta-data command evaluated first, and only pass the result to the triggered pipeline?

Hey @rryan !

Sure, to pass down meta-data you will need to use dynamic pipeline upload (Defining your pipeline steps | Buildkite Documentation) which is a bash script that generates more scripts, so you can interpolate any variables you want in there.

# Pipeline A (This should be uploaded using the dynamic pipelines) 
steps:
  - trigger: pipeline-b
    label: "Trigger B"
    build:
      meta_data:
        triggered-from-job-id: "${BUILDKITE_JOB_ID}"

# Pipeline B
steps:
  - command: buildkite-agent meta-data get "triggered-from-job-id"

Thanks,