# Create tag release with commit hash

**URL:** <https://forums.balena.io/t/create-tag-release-with-commit-hash/36416>\
**Category:** Product support\
**Created:** [October 11, 2019, 12:33pm UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416 "2019-10-11T12:33:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![benat](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@benat](https://forums.balena.io/u/benat)\
**Post date:** [October 11, 2019, 12:33pm UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/1 "2019-10-11T12:33:09Z")

</div>

Hi,

I am actually trying to establish integration continious process with Gitlab CI. Building and deploying stages are ok. Now I am trying to create tag with release hash returned by balena deploy command. This operation failed at the moment.

When I try with Balena CLI v11.9.3 I have this error :

```
balena tag set test 'aaa' --release 9c9d97973bb33f5fa83e1c9a059e73df
BalenaRequestError: Request error: Database error

Additional information may be available by setting a DEBUG=1 environment
variable: "set DEBUG=1" on a Windows command prompt, or "export DEBUG=1"
on Linux or macOS.

If you need help, don't hesitate in contacting our support forums at
https://forums.balena.io

For bug reports or feature requests, have a look at the GitHub issues or
create a new one at: https://github.com/balena-io/balena-cli/issues/

```

When I try with Balena NodeJS SDK, I have the same error :

```
Unhandled rejection BalenaRequestError: Request error: Database error
    at /home/benjamin/Documents/Balena/Client_API_Balena/node_modules/balena-request/build/request.js:197:17
    at tryCatcher (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate (internal/timers.js:439:21)

```

With Balena API, I don’t find correct request to create tag release.

Can I have support to finalize my operation ? Preferably, I would like to create tag release with APi request.

Thanks,  
Ben

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [October 11, 2019, 1:50pm UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/2 "2019-10-11T13:50:54Z")

</div>

Hello, I’m having a look

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [October 11, 2019, 1:54pm UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/4 "2019-10-11T13:54:52Z")

</div>

Could you try using the release id (the one at the end of the url on the release dashboard page) instead of the uuid?

---

<div class="post-metadata">

**Author:** ![benat](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@benat](https://forums.balena.io/u/benat)\
**Post date:** [October 14, 2019, 5:29am UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/6 "2019-10-14T05:29:13Z")

</div>

With release id it’s ok. When I deploy project, I have only release hash. It’s the reason that I would have liked use it in the request. I worked around by getting release id with release hash by using API.

I think there are an issue on SDK request. I had Database error with this request :

```auto
balena.models.release.get(123).then(function(37d7c583ec5fcdfb826b432d30c4b74f'') {
        console.log(release);
});

```

And with the API equivalent it’s worked fine.

```
https://api.balena-cloud.com/v4/release?\$filter=commit%20eq%20'37d7c583ec5fcdfb826b432d30c4b74f'&\$select=id" \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $TOKEN

```

Can I have the API route equivalent of this balena cli request ?

`balena tag set Version $VERSION --release $RELEASEID`

Thanks,  
Benjamin

---

<div class="post-metadata">

**Author:** ![xginn8](https://avatars.discourse-cdn.com/v4/letter/x/8baadc/32.png) [@xginn8](https://forums.balena.io/u/xginn8)\
**Post date:** [October 14, 2019, 6:52pm UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/7 "2019-10-14T18:52:34Z")

</div>

Hi @benat,

That first example looks like it might be malformed, you should replace the `123` with whatever you are querying (that’s just an example placeholder). Instead, you could try:

```auto
balena.models.release.get('37d7c583ec5fcdfb826b432d30c4b74f').then(function() {
        console.log(release);
});

```

Please let us know if you have any further issues! I’ve just confirmed locally that this call returns a release object.

---

<div class="post-metadata">

**Author:** ![benat](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@benat](https://forums.balena.io/u/benat)\
**Post date:** [October 15, 2019, 11:47am UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/9 "2019-10-15T11:47:01Z")

</div>

Hi,

It’s an copy error by writing the post. I replaced correctly 123 by release hash or id. With the release id, I get a release object. And with the release hash I get the Database error.

Ben

---

<div class="post-metadata">

**Author:** ![thgreasi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thgreasi/32/454_2.png) [@thgreasi](https://forums.balena.io/u/thgreasi)\
**Post date:** [October 15, 2019, 5:51pm UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/10 "2019-10-15T17:51:45Z")

</div>

Hi,  
Could you upgrade your balena-cli to at least 11.9.6 and give it an extra try?

Could you provide us the exact error from when using the sdk method?  
You might get an ambiguity error if you also have other apps with a release with the same hash, or if there is also a failed release with the same hash.  
You can use something like the following that adds a few extra filters to find an unambiguous result:

```auto
sdk.models.release.getAllByApplication('myApp' /* this can also be an app id */, {
	$filter: {
		commit: 'a0ab85f11a33762000b1c1c419cb697e59456328',
		status: 'success'
    }
}).then(console.log);

```

Let me point you to the documentation for that method:

> <https://github.com/balena-io/balena-sdk/blob/master/DOCUMENTATION.md#balena.models.release.getAllByApplication>

---

<div class="post-metadata">

**Author:** ![thgreasi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thgreasi/32/454_2.png) [@thgreasi](https://forums.balena.io/u/thgreasi)\
**Post date:** [October 15, 2019, 5:52pm UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/11 "2019-10-15T17:52:31Z")

</div>

Also, which version of the balena-sdk are you using?

---

<div class="post-metadata">

**Author:** ![benat](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@benat](https://forums.balena.io/u/benat)\
**Post date:** [October 16, 2019, 5:27am UTC](https://forums.balena.io/t/create-tag-release-with-commit-hash/36416/13 "2019-10-16T05:27:29Z")

</div>

Hi,

Thanks for your response. It’s work fine with extra filters.

I work with balena sdk version 11.17.0.  
Without filters, I get this error :

```
Unhandled rejection BalenaRequestError: Request error: Database error
    at /home/benjamin/Documents/Balena/Client_API_Balena/node_modules/balena-request/build/request.js:197:17
    at tryCatcher (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/benjamin/Documents/Balena/Client_API_Balena/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate (internal/timers.js:439:21)

```

Thank for all,  
Ben
