# Dynamically trigger pipelines via buildkite-agent

**URL:** <https://forum.buildkite.community/t/dynamically-trigger-pipelines-via-buildkite-agent/437>\
**Category:** Features Requests\
**Created:** [April 19, 2019, 10:54am UTC](https://forum.buildkite.community/t/dynamically-trigger-pipelines-via-buildkite-agent/437 "2019-04-19T10:54:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![azz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/azz/32/462_2.png) [@azz](https://forum.buildkite.community/u/azz)\
**Post date:** [April 19, 2019, 10:54am UTC](https://forum.buildkite.community/t/dynamically-trigger-pipelines-via-buildkite-agent/437/1 "2019-04-19T10:54:56Z")

</div>

The pipeline trigger step is great, but sometimes we don’t know _which_ pipelines we want to trigger until mid-way through a build.

Currently we solve this by using the REST API during the execution of a step to invoke a new build. The down side of this is that the triggered builds don’t show up in the Buildkite UI for the current build.

It would be awesome if there was a command in `buildkite-agent` to do this. Something like:

```auto
buildkite-agent build create --pipeline my-pipeline \
  --commit HEAD \
  --branch master \
  --message "my message" \
  --env '{}' \
  --meta-data '{}'

```

These build would be asynchronous to the current build.

---

<div class="post-metadata">

**Author:** ![anon18197598](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@anon18197598](https://forum.buildkite.community/u/anon18197598)\
**Post date:** [April 21, 2019, 4:08am UTC](https://forum.buildkite.community/t/dynamically-trigger-pipelines-via-buildkite-agent/437/2 "2019-04-21T04:08:47Z")

</div>

Hey @azz 👋🏻

You can do this currently with dynamic pipeline uploads as a step in your pipeline:

```bash
cat <<YAML | buildkite-agent pipeline upload
steps:
  - name: ":rocket:"
    trigger: "${pipeline}"
    async: false
    branches: "${branch}"
    build:
      message: "My message for the build"
      commit: "${BUILDKITE_COMMIT}"
      branch: "${BUILDKITE_BRANCH}"
YAML 

```

Check out the script we use in the Agent pipeline: [https://github.com/buildkite/agent/blob/master/.buildkite/steps/upload-release-steps.sh](https://github.com/buildkite/agent/blob/master/.buildkite/steps/upload-release-steps.sh)

---

<div class="post-metadata">

**Author:** ![azz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/azz/32/462_2.png) [@azz](https://forum.buildkite.community/u/azz)\
**Post date:** [April 23, 2019, 10:21am UTC](https://forum.buildkite.community/t/dynamically-trigger-pipelines-via-buildkite-agent/437/3 "2019-04-23T10:21:10Z")

</div>

Perfect, thanks! For some reason I thought you couldn’t do this, but it works perfectly!
