Programmatically Creating & Updating Workspace and Repository Runners
Asked by Gajesh Bhat:

Hello Atlassian Community,

I am looking to automate the management of workspace and repository runners in Bitbucket Cloud and Bitbucket Pipelines. Specifically, I want to create and update these runners programmatically, ideally using an API or a similar method. This would allow me to manage runner configurations dynamically as part of our CI/CD processes.

Could anyone provide guidance or examples on how to achieve the following using Bitbucket's API or any other method:

1. Programmatically create a new runner for a workspace or a specific repository.
2. How to know when a new Runner is released and obtain it's version so that I can setup a Cron job to automatically download and apply the updates. The Current Bitbucket Cloud API seems to not support this feature out of the box.
3. Optionally, if there are best practices for managing runners in a dynamic and scalable way, I'd be keen to learn about those too.

I saw an open ticket and some discussions about workarounds. Does Atlassian have any recommended methods to set this up ? [BCLOUD-22032 : Runner Update Options](https://jira.atlassian.com/browse/BCLOUD-22032)

Any help or pointers towards relevant documentation would be greatly appreciated!

Regards,

Gajesh


Answers:
author: Patrik S
body: Hello [@Gajesh Bhat](/t5/user/viewprofilepage/user-id/5324120) ,

thank you for reaching out to the Community!

I would suggest taking a look at the runner's autoscaler tool release last year that can be deployed into a kubernetes environment and already contains the logic to scale the number of runners similar to what you described in your question :

* <https://bitbucket.org/blog/runners-autoscaler>

Bitbucket Cloud currently doesn't have public API endpoints for managing runners, so the auto scaler tool makes use of internal API endpoints to make the requests to create/delete runners. Those are the same internal APIs used by the UI when making such actions in the Bitbucket portal.

Also, the good thing about the autoscaler tool is that its source code is published in a public repository, so if you have different requirements and cannot leverage the autoscaler for your use case, you can still dive into its code to have more details about the implementations and the APIs being used, and come up with your own solution :

* <https://bitbucket.org/bitbucketpipelines/runners-autoscaler>

Lastly, for the runner's auto-update functionality, currently, the runners can only be updated manually or, as a workaround, through custom scripts as suggested by other users in the feature request [BCLOUD-22032](https://jira.atlassian.com/browse/BCLOUD-22032). There's not a native functionality for this porpoise yet, as this is being tracked and considered as a future implementation on that feature ticket.

If you would be interested in that, we encourage you to add your ***Vote*** to the feature to increase its visibility and also mark yourself as a ***watcher*** so you get notified about any future updates.

I hope that helps! Should you have any questions, let us know!

Thank you, [@Gajesh Bhat](/t5/user/viewprofilepage/user-id/5324120) !

Patrik S

comments: author: Gajesh Bhat
body: Thank you [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) I will use a workaround until the feature is officially supported. I also found a link where the Release notes for Bitbucket Pipeline Runners are posted. Is this page consistent ? Can I point my script to parse this page to look for the latest runner version ? Link to Changelog <https://product-downloads.atlassian.com/software/bitbucket/pipelines/CHANGELOG.md>


author: Patrik S
body: Hey [@Gajesh Bhat](/t5/user/viewprofilepage/user-id/5324120) ,

Yes, you can use that page to get updates on new runner versions being released.


Tags: atl-esc

bitbucket-cloud

bitbucket-pipelines

bitbucket-runners

cloud