Bulk update Self-hosted runners on the same host
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
When a new version of Runners is released, it is important to note that Bitbucket Pipelines Runners do not automatically update by default; manual updates are required.
In scenarios where multiple Runners are operating under the same host, to streamline the update process and avoid the need to manually update each Runner individually with each new version release, it is feasible to implement a configuration using Docker Compose. This setup allows for the automatic checking of newer versions, enabling the bulk update of all Runners without the necessity of restarting each one manually.
Environment
Bitbucket Pipelines Self-hosted Runners on any environment.
Solution
The following setup can be used to have Docker Compose update all Runners in bulk:
On the host machine that is executing the Runner, create a docker-compose.yml like the one below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
version: '3.8' services: runner-1: image: docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner volumes : - /tmp:/tmp - /var/run/docker.sock:/var/run/docker.sock - /var/lib/docker/containers:/var/lib/docker/containers:ro environment: - ACCOUNT_UUID={<accountUUID>} - REPOSITORY_UUID={<repoUUID} - RUNNER_UUID={runnerUUID} - OAUTH_CLIENT_ID=<OAuthClientID> - OAUTH_CLIENT_SECRET=<OAuthClientSecret> - WORKING_DIRECTORY=/tmp container_name: runner-1 restart: always
⚠️ It is essential to ensure that the variables mentioned above are substituted with the appropriate values relevant to your Runner. Additionally, it is important to replace the service name and container name with the specific names corresponding to each runner, allowing for the inclusion of multiple services as per your requirements.
Run the following command to start Docker Compose:
1
docker-compose up -d
This should start the Docker compose service. You can check the Runner container statuses with the following command:
1
docker compose stats --no-stream
Once a new version of Runners comes out, you can run the following command to take down all of the Runners:
1
docker-compose down --rmi all
A message like the one below will appear on the build setup of builds running under this host, if an update for Runners is available :
The version of this runner is outdated. Upgrade to the latest version
After taking down all of the Runners, you can restart them by running the following command again. This command will pull the newer Runner image version.
1
docker-compose up -d
Was this helpful?