# Can our Builder build see our Git revision hash?

**URL:** https://discourse.chef.io/t/can-our-builder-build-see-our-git-revision-hash/18908
**Category:** Habitat Help
**Created:** [April 18, 2018, 3:28pm UTC](https://discourse.chef.io/t/can-our-builder-build-see-our-git-revision-hash/18908 "2018-04-18T15:28:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![smartb-pair](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/smartb-pair/32/2735_2.png) [@smartb-pair](https://discourse.chef.io/u/smartb-pair)
#### Post date: [April 18, 2018, 3:28pm UTC](https://discourse.chef.io/t/can-our-builder-build-see-our-git-revision-hash/18908/1 "2018-04-18T15:28:32Z")

</div>

We’d love to be able to send notifications to various monitoring services that would record the Git revision that’s been deployed or packaged. Is there a way to see the Git revision from inside the build Studio or from inside Builder when a GitHub webhook has triggered a build?

---

<div class="post-metadata">

### Author: ![joshb](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshb/32/2380_2.png) [@joshb](https://discourse.chef.io/u/joshb)
#### Post date: [April 18, 2018, 4:43pm UTC](https://discourse.chef.io/t/can-our-builder-build-see-our-git-revision-hash/18908/2 "2018-04-18T16:43:23Z")

</div>

As far as I can tell, no, this functionality doesn’t currently exist. We’re always open to new feature requests, though.

---

<div class="post-metadata">

### Author: ![baumanj](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/baumanj/32/2751_2.png) [@baumanj](https://discourse.chef.io/u/baumanj)
#### Post date: [April 18, 2018, 6:21pm UTC](https://discourse.chef.io/t/can-our-builder-build-see-our-git-revision-hash/18908/3 "2018-04-18T18:21:30Z")

</div>

I haven’t fully explored this, but I think you should be able to add `core/git` as a build dependency and then stash the output of

```
git rev-parse HEAD

```

somewhere in the build output to be accessed later. Would that work for your purposes, @smartb-pair?

---

<div class="post-metadata">

### Author: ![cnunciato](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cnunciato/32/2699_2.png) [@cnunciato](https://discourse.chef.io/u/cnunciato)
#### Post date: [April 30, 2018, 11:32pm UTC](https://discourse.chef.io/t/can-our-builder-build-see-our-git-revision-hash/18908/4 "2018-04-30T23:32:00Z")

</div>

This comes up all the time and would be really useful. I've created an issue for it here:

> <https://github.com/habitat-sh/builder/issues/407>
>
> This request comes up often:
> https://forums.habitat.sh/t/can-our-builder-build-see-our-git-revision-hash
> It'd be nice to capture the SHA (e.g., from a webhook or CLI argument) and expose it...

---

<div class="post-metadata">

### Author: ![smartb-pair](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/smartb-pair/32/2735_2.png) [@smartb-pair](https://discourse.chef.io/u/smartb-pair)
#### Post date: [May 3, 2018, 2:18pm UTC](https://discourse.chef.io/t/can-our-builder-build-see-our-git-revision-hash/18908/5 "2018-05-03T14:18:09Z")

</div>

Yes, that does work and we can probably use this for a few things. Thanks!

---

<div class="post-metadata">

### Author: ![Steve\_Hummingbird](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Steve\_Hummingbird](https://discourse.chef.io/u/Steve_Hummingbird)
#### Post date: [June 27, 2018, 11:34am UTC](https://discourse.chef.io/t/can-our-builder-build-see-our-git-revision-hash/18908/6 "2018-06-27T11:34:00Z")

</div>

In case someone comes along here searching for a solution - especially on how to “stash” the output. I was able to use the `do_build()` method to supply the git revision:

```
do_build() {
  set_runtime_env GIT_REVISION $(git rev-parse HEAD 2>&1)
}

```

The 2\>&1 redirect should not be totally necessary though.  
And in the corresponding hook I am including it like any other environment variable in a curl command to notify about the deployment:

`curl https://monitoring.domain -F revision=$GIT_REVISION`

If anyone comes across a better solution, please do let us know.
