# Use previous step info for trigger step build info

**URL:** <https://forum.buildkite.community/t/use-previous-step-info-for-trigger-step-build-info/2244>\
**Category:** General\
**Created:** [September 14, 2022, 7:57am UTC](https://forum.buildkite.community/t/use-previous-step-info-for-trigger-step-build-info/2244 "2022-09-14T07:57:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FNK](https://avatars.discourse-cdn.com/v4/letter/f/ac8455/32.png) [@FNK](https://forum.buildkite.community/u/FNK)\
**Post date:** [September 14, 2022, 7:57am UTC](https://forum.buildkite.community/t/use-previous-step-info-for-trigger-step-build-info/2244/1 "2022-09-14T07:57:59Z")

</div>

Hi everyone!!

I am trying to use the information of one step to configure a `trigger step`, in specific, on the step I will get a commit hash and then I want to use it to trigger another pipeline over that specific commit.

Is there a chance to do that? I know I can use that information on the next step by using meta-data but I don’t know how to read it on this case that I don’t want to use it inside the commands but in the step config.

```auto
# steps:

steps:
  - label: "Set hash"
    commands:
      - export commit-hash = "346104832969fe31b25760172aba0a84e9c22457" // This is here hardcoded but I get this dynamically from an API and some calculations.
  - wait
  - trigger: my-other-pipeline
     build:
       branch: "${BUILDKITE_BRANCH}"
       message: "${BUILDKITE_MESSAGE}"
       commit: "" // I want to use here the commit-hash

```

I haven’t been able to see the way to achieve that.

---

<div class="post-metadata">

**Author:** ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)\
**Post date:** [September 14, 2022, 8:04am UTC](https://forum.buildkite.community/t/use-previous-step-info-for-trigger-step-build-info/2244/2 "2022-09-14T08:04:22Z")

</div>

Hey @FNK welcome and good question 👍

This is definitely possible. There is the [BUILDKITE\_COMMIT](https://buildkite.com/docs/pipelines/environment-variables#BUILDKITE_COMMIT) environment variable that houses the commit hash, just like the other env vars you’ve used there. That should give you want you want - to trigger the other pipeline against the specific commit

---

<div class="post-metadata">

**Author:** ![FNK](https://avatars.discourse-cdn.com/v4/letter/f/ac8455/32.png) [@FNK](https://forum.buildkite.community/u/FNK)\
**Post date:** [September 14, 2022, 8:06am UTC](https://forum.buildkite.community/t/use-previous-step-info-for-trigger-step-build-info/2244/3 "2022-09-14T08:06:04Z")

</div>

Hi @paula, thank you for the answer.

The thing is that I am running my pipeline against HEAD and I want to trigger the other pipeline over a different commit that I get on the first step.

AFAIK BUILDKITE\_COMMIT cannot be modified.

---

<div class="post-metadata">

**Author:** ![suma](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/suma/32/1306_2.png) [@suma](https://forum.buildkite.community/u/suma)\
**Post date:** [September 14, 2022, 4:37pm UTC](https://forum.buildkite.community/t/use-previous-step-info-for-trigger-step-build-info/2244/4 "2022-09-14T16:37:58Z")

</div>

Hi @FNK,

As shown in below example, you can also set the commit that you want the other pipeline to run when you trigger it

```auto
- trigger: "app-sub-pipeline"
  label: "Sub-pipeline"
  build:
    message: "${BUILDKITE_MESSAGE}"
    commit: "<SET_VALUE_OF_COMMIT>"
    branch: "${BUILDKITE_BRANCH}"

```
