# Pass metadata to triggered pipelines with pure YAML

**URL:** <https://forum.buildkite.community/t/pass-metadata-to-triggered-pipelines-with-pure-yaml/875>\
**Category:** Features Requests\
**Created:** [January 21, 2020, 6:45pm UTC](https://forum.buildkite.community/t/pass-metadata-to-triggered-pipelines-with-pure-yaml/875 "2020-01-21T18:45:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwmaier](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/cwmaier/32/713_2.png) [@cwmaier](https://forum.buildkite.community/u/cwmaier)\
**Post date:** [January 21, 2020, 6:45pm UTC](https://forum.buildkite.community/t/pass-metadata-to-triggered-pipelines-with-pure-yaml/875/1 "2020-01-21T18:45:49Z")

</div>

I’ll paste the interaction [from Slack](https://buildkite-community.slack.com/archives/C02T53V9H/p1579298126004400) for posterity:

When using a trigger step ([https://buildkite.com/docs/pipelines/trigger-step](https://slack-redir.net/link?url=https%3A%2F%2Fbuildkite.com%2Fdocs%2Fpipelines%2Ftrigger-step&v=3)), I see that we can pass meta-data to the triggered pipeline. I have some data that I generate and set as meta-data within the triggering pipeline that I’d like to pass to the triggered pipeline. Absent dynamically generating the content of the trigger step, is there any way I can set this up using pure YAML? Something like, say:

```auto
- trigger: "dependent-pipeline"
  label: "Doing nifty things"
  build:
    meta_data:
    - key_that_i_set_earlier_in_the_triggering_pipeline

```

And @anon85971592 responded:

> Hey @cm! It’s a good question! The only way to do it at the moment is to have a step that re-generates the trigger step at runtime and pipeline uploads it  
> (basically kinda what you were thinking)  
> However, I hadn’t considered the docker-compose model before as a quick shortcut…  
> Can you shoot this through to support and say “Keith said this could be a good idea?”

Thanks!

---

<div class="post-metadata">

**Author:** ![carl](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@carl](https://forum.buildkite.community/u/carl)\
**Post date:** [June 26, 2020, 8:28am UTC](https://forum.buildkite.community/t/pass-metadata-to-triggered-pipelines-with-pure-yaml/875/2 "2020-06-26T08:28:32Z")

</div>

+1 to this - we have a lot of pipelines which trigger other pipelines with dynamic metadata.

e.g:

```auto
steps:
  - command: "create_deployment.sh" # sets deployment-name metadata

  - wait: ~

  # script which reads metadata + uploads trigger step below
  - command: "profile_deployment.sh" 

```

```auto
  - trigger: "deployment-profiling"
    build:
       meta_data:
          # has to be resolved by script, doesnt work in steps.yaml
          deployment-name: $(buildkite-agent meta-data get deployment-name) 

```

It would be ideal if we could remove the `profile_deployment.sh` script and just directly put that trigger step into the yaml

---

<div class="post-metadata">

**Author:** ![Jason](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/jason/32/742_2.png) [@Jason](https://forum.buildkite.community/u/Jason)\
**Post date:** [June 29, 2020, 1:43am UTC](https://forum.buildkite.community/t/pass-metadata-to-triggered-pipelines-with-pure-yaml/875/3 "2020-06-29T01:43:53Z")

</div>

This is a great idea, thanks for taking the time to raise this! I have raised this internally with the team!

---

<div class="post-metadata">

**Author:** ![donal](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/donal/32/1126_2.png) [@donal](https://forum.buildkite.community/u/donal)\
**Post date:** [February 4, 2023, 3:20pm UTC](https://forum.buildkite.community/t/pass-metadata-to-triggered-pipelines-with-pure-yaml/875/4 "2023-02-04T15:20:23Z")

</div>

Hey, I’ve seen this idea floated around in a few places, and I’d like to ask is there any update on this feature? I’d be happy to submit a PR to implement it, but unfortunately I would need some help finding where this behaviour happens on the agent.

Our specific use case for this is that we have build with lots of options, and we have some defaults set for UI triggered builds, but we’d like to add a second “advanced” build that just triggers the first with some metadata customised. It would be _really_ great if we didn’t have to duplicate the metadata parsing logic in both pipelines in a script, and instead could just do:

```auto
- trigger: "multi-option-build"
  build:
    meta_data:
        option_a: "meta:option_a"
        option_b: "meta:option_b"

```

---

<div class="post-metadata">

**Author:** ![karen.sawrey](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/karen.sawrey/32/1188_2.png) [@karen.sawrey](https://forum.buildkite.community/u/karen.sawrey)\
**Post date:** [February 10, 2023, 6:51pm UTC](https://forum.buildkite.community/t/pass-metadata-to-triggered-pipelines-with-pure-yaml/875/5 "2023-02-10T18:51:47Z")

</div>

Welcome back to the forum, @Donal! Thank you for your suggestion!

Unfortunately, metadata is not handled by the Buildkite agent but by Buildkite itself, so a PR for an agent will not solve your issue. The idea of implementing passing metadata to triggered pipelines with YAML has been floating around for some time [on the forum](https://forum.buildkite.community/t/pass-metadata-to-triggered-pipelines-with-pure-yaml/875/2). However, for the time being, the only possible workaround is using [dynamic pipelines](https://buildkite.com/docs/pipelines/defining-steps#dynamic-pipelines), [trigger step](https://buildkite.com/docs/pipelines/trigger-step), and a command to [get metadata](https://buildkite.com/docs/pipelines/build-meta-data) from the trigger pipeline.

You’ll need the trigger **ed** pipeline (Pipeline B) to use the command `buildkite-agent meta-data get "release-version"` in the pipeline steps to get the metadata contained in the trigg **er** pipeline (Pipeline A).

For example:

Pipeline A (trigger)

```auto
steps:
  - trigger: pipeline-b-slug
    build: 
      meta_data:
        release-version: "2.0"

```

Pipeline B (triggered)

```auto
steps:
  - command: echo $(buildkite-agent meta-data get "release-version")

```

I hope this helps.

Cheers!
