Create tag release with commit hash

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

Hello, I’m having a look

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

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 :

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

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:

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.

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

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:

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:

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

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