I’m trying to use the Balena API to update the release assigned to a number of devices in my app, depending on the values of some of the tags I’ve assigned to the devices.
For example in the app ‘Jason’, I want to set the release for all devices with the tags ‘my.environment’ set to ‘debug’ and ‘my.location’ set to home.
Hi there, the scripts simply call our API, so you can do the same and modify them to your needs. The scripts have the version hard-coded currently to v5, so they should work for v5 without any issues. Can you please share how you are calling the script?
These used to work - they’re based on the code in the shell script above - and they used to return a collection of devices with the matching labels and contents. I could then issue an HTTP PATCH in the format:
{“should_be_running__release”:“<RELEASE_ID>”}
to the same URL, and that used to update all of the devices, and make them download the latest release.
Now when I issue the GET command for URLs in that format I get “Malformed URL”
It is a bit difficult to see what is wrong in the URL, but maybe something changed in the API that made your URL not work. On a positive note, we will soon release this functionality in the dashboard, so you won’t need custom scripts. I will check in a bit more detail what changed to affect this and test the staged releases scripts if there was some regression there as well.
Hi - the script doesn’t actually do precisely what I need - I need to compare the presence and values of two tags on a release, not just the one that the script handles.
I see, that wasn’t clear to me initially. In that case, what I would suggest is cloning the staged-releases scripts, adding the changes you have mentioned before, and see if that works better. What you have done above should work, but in the form posted it is really difficult to debug where the issue lies. As I said, we should surface this in the dashboard soon, so you will be able to filter by tag there and pin devices to a specific release.