# Pass PR labels to a triggered child build

**URL:** <https://forum.buildkite.community/t/pass-pr-labels-to-a-triggered-child-build/1486>\
**Category:** Pipelines\
**Created:** [March 9, 2021, 11:25am UTC](https://forum.buildkite.community/t/pass-pr-labels-to-a-triggered-child-build/1486 "2021-03-09T11:25:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![obrisse](https://avatars.discourse-cdn.com/v4/letter/o/35a633/32.png) [@obrisse](https://forum.buildkite.community/u/obrisse)\
**Post date:** [March 9, 2021, 11:25am UTC](https://forum.buildkite.community/t/pass-pr-labels-to-a-triggered-child-build/1486/1 "2021-03-09T11:25:59Z")

</div>

Hi,

I’m trying to have a step in triggered child pipeline being dependent on the PR label.

The child pipeline is triggered by a `trigger` step and as per the [documentation](https://buildkite.com/docs/pipelines/trigger-step#environment-variables), the branch and pull request environment variables are passed through:

```yaml
  - trigger: "web-tests"
    label: ":hammer: Test"
    async: true
    build:
      message: "${BUILDKITE_MESSAGE}"
      commit: "${BUILDKITE_COMMIT}"
      branch: "${BUILDKITE_BRANCH}"
      env:
        BUILDKITE_PULL_REQUEST: "${BUILDKITE_PULL_REQUEST}"
        BUILDKITE_PULL_REQUEST_BASE_BRANCH: "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}"
        BUILDKITE_PULL_REQUEST_REPO: "${BUILDKITE_PULL_REQUEST_REPO}"

```

However, this doesn’t seem to work with the `build.pull_request` variables on the child pipeline.

I’ve tried the following expressions:

```auto
build.pull_request.labels includes "my-label"
build.pull_request.draft

```

and they both don’t work.

Am I missing something?

---

<div class="post-metadata">

**Author:** ![juanitofatas](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/juanitofatas/32/957_2.png) [@juanitofatas](https://forum.buildkite.community/u/juanitofatas)\
**Post date:** [March 11, 2021, 7:12am UTC](https://forum.buildkite.community/t/pass-pr-labels-to-a-triggered-child-build/1486/2 "2021-03-11T07:12:38Z")

</div>

Hi Olivier,

I am afraid we currently don’t have built-in support for this and you will need to use the [GitHub Labels API](https://docs.github.com/en/rest/reference/issues#labels) to find those labels and triggered the right pipeline.

I’m sorry it’s not available right now, but I have filed your usecase internally as a feature request to the team that I hope we can add this in the future for you.

Best,  
Juanito

---

<div class="post-metadata">

**Author:** ![obrisse](https://avatars.discourse-cdn.com/v4/letter/o/35a633/32.png) [@obrisse](https://forum.buildkite.community/u/obrisse)\
**Post date:** [March 15, 2021, 9:31pm UTC](https://forum.buildkite.community/t/pass-pr-labels-to-a-triggered-child-build/1486/3 "2021-03-15T21:31:13Z")

</div>

Thanks Juanito.

In the meantime, I got something working by using build meta-data and dynamic pipeline.

On the first pipeline, I have one step that use the conditional to set metadata:

```
  - label: ":triangular_flag_on_post:"
    command: buildkite-agent meta-data set "my-flag" "true"
    if: "build.pull_request.labels includes \"my label\""

```

I’ve then modified my trigger step to [dynamically upload itself](https://buildkite.com/docs/pipelines/block-step#passing-block-step-data-to-other-steps-passing-meta-data-to-trigger-steps) to the pipeline and set the `env` variables based on the meta-data set in that previous step.

```
- command: ".buildkite/trigger-tests.sh"
  label: ":hammer: Test"

```

`.buildkite/trigger-tests.sh`:

```
#!/bin/bash

set -euo pipefail

# Set up a variable to hold the meta-data from previous steps
MY_FLAG="$(buildkite-agent meta-data get "my-flag" --default "")"

# Create a pipeline with the trigger step
PIPELINE="steps:
  - trigger: \"web-tests\"
    label: \":hammer: Test\"
    async: true
    build:
      message: ${BUILDKITE_MESSAGE}
      commit: ${BUILDKITE_COMMIT}
      branch: ${BUILDKITE_BRANCH}
      env:
        BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}
        BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
        BUILDKITE_PULL_REQUEST_REPO: ${BUILDKITE_PULL_REQUEST_REPO}
        MY_FLAG: ${MY_FLAG}
"

# Upload the new pipeline and add it to the current build
echo "$PIPELINE" | buildkite-agent pipeline upload
```

---

<div class="post-metadata">

**Author:** ![tetienne](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@tetienne](https://forum.buildkite.community/u/tetienne)\
**Post date:** [January 31, 2023, 2:26pm UTC](https://forum.buildkite.community/t/pass-pr-labels-to-a-triggered-child-build/1486/4 "2023-01-31T14:26:21Z")

</div>

Hi,

2 years later, it seems this limitation still exist, I was going crazy facing this issue until I found this topic. I would be nice to update the documentation with this corner case, or even better to fix it.

---

<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:** [January 31, 2023, 6:16pm UTC](https://forum.buildkite.community/t/pass-pr-labels-to-a-triggered-child-build/1486/5 "2023-01-31T18:16:15Z")

</div>

Hello, @tetienne! Thank you for your feedback! We’ll analyze what can be done about this!

Best!
