Tag release during project deploiement


I want to add build/deploy stage on my Gitlabs CI. My issue is to have access at release key/Id created when project is deployed on Balena registry. I search solution to get release key/id from BalenaAPI/SDK.

I thought about tag. On SDK library, I see balena.models.release.tags.set (..) but this service is to tag release after project deployment and need to have release commit or id. Is it possible to tag release during deployment operation ? I don’t see this option on balena cli doc.

Or have you an other solution for my issue ?


Hi there, let’s clarify first what exactly you are trying to achieve, and then figure out the best way to do it.
Are you trying to build the images on your servers, or do you just want to push code to balena’s builders? Why do you need the releaseId in the first place?

If you are trying to push your repo to our builders, you can use the CLI’s detached mode, which will give you back the releaseID once the build starts.

I am trying to build the image on our server and push the image on your registry if build and validation test are ok. I need the releaseId to allow my application server to make update operation via pin to release mode of BalenaCloudAPI.

Below is scenario desired :

Operator  -> Gitlabs CI : git push project with tag v12 

(if build and test are ok) Gitlabs CI -> BalenaCloud  balena build (OK) -> balena deploy with tag v12

AppServer -> BalenaCloud : get releaseID matching tag V12
AppServer <- BalenaCloud : return releaseID

AppServer -> BalenaCloud : pin to new releaseID  group of device 


I understand much better now, thanks.

What I think you can do for now is the following:

  • Once the images are built on your server, you can run balena deploy <appname> <image>
  • Since currently there is not detached/headless mode for deploy, you can try and parse the logs that are returned from balena deploy. If successful, it should print something like "Release: #{release.commit}" to the console, from where you can extract the release commit.
  • Afterwards, you can use the API/SDK to do the rest of the actions using the release UUID.

I will also open an issue in the CLI to support --detached mode for deploy as well. How does that sound?

Ok so I must create a process to extract the release commit on log and push it to my app server. It’s not the best solution because I prefer avoid direct exchange between CI pipeline and app server.
Thanks for you helps,

FYI, We are tracking a detached mode request for the deploy command with this github ticket:

Until it’s done, the only other suggestion I have is using balena SDK/API to get a list of application releases and picking a recent release by its timestamp. I understand it’s not good either, but it might be better than parsing command output in some cases.