Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,672
Community Members
 
Community Events
176
Community Groups

Update local runner for Bitbucket Pipelines

When running my pipelines, I am getting this notification:


The version of this runner is outdated. Upgrade to the latest version

I tried looking in the documentation but I was not able to find a solution.

How can I update my local Runners?

 

4 answers

1 accepted

0 votes
Answer accepted

Hi @ethan_chen,

You can update the runner with the following command:

docker image pull docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1

In case you encounter the following error:

docker: Error response from daemon: docker: Error response from daemon: Conflict. The container name "/runner-76b247e7-b925-5e7b-9da2-1cda14c4ff2c" is already in use by container "c3403236e3af5962ed3a9b8771561bd2021974941cc8a89a40c6c66cecb18f53". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.

First, remove the runner with the following command, and then execute the docker image pull command I mentioned above:

docker container rm -f runner-76b247e7-b925-5e7b-9da2-1cda14c4ff2c

Replace runner-76b247e7-b925-5e7b-9da2-1cda14c4ff2c in the command with the name of your runner.

This is documented here for easier reference:

After you have updated the runner, you can use the pre-configured Docker command that you were given when you created the runner, in order to start it again.

Please feel free to let me know if you have any questions!

Kind regards,
Theodora

Hi Theodora,

what about runners in Windows?

Hi @Sturla Lange,

For Windows runners you'll need to download and extract the zip file of the latest version and then start the runner from the directory of the latest version.

When you create a Windows runner from the Bitbucket website, the first 3 commands that are given are the following:

Invoke-WebRequest -Uri https://product-downloads.atlassian.com/software/bitbucket/pipelines/atlassian-bitbucket-pipelines-runner-1.315.zip -OutFile .\atlassian-bitbucket-pipelines-runner.zip

Expand-Archive .\atlassian-bitbucket-pipelines-runner.zip

cd .\atlassian-bitbucket-pipelines-runner\bin

The version in the zip file will be different if there is a newer version available.

What you can do is:
- stop the existing runner
- delete the existing atlassian-bitbucket-pipelines-runner.zip file and atlassian-bitbucket-pipelines-runner directory to avoid any confusion
- then download the new version and extract the zip file with the commands above
- use the last command (not included in the list above) to start the runner from the new directory

Edit: there is no other way to check for the newest version of Windows runners at the moment.

Kind regards,
Theodora

Like Sturla Lange likes this

this downloads a new image, but doesn't actually update a existing runner,

Hi @Theodora Boudale ,

Is there any web page that lists all of the possible runner versions that can be downloaded? I can't find one. I'm looking for a page/list of runner versions so that my PowerShell script can pick the latest one to determine if there are any updates and auto update, if there is, according to your instructions.

Without this we cannot automate our runner update process.

 

Thanks

Hi Nathan,

I'm afraid that we don't have such a page available at the moment.

There is a feature request in our issue tracker which includes this suggestion: https://jira.atlassian.com/browse/BCLOUD-22032 Since you'd be interested in that, I would recommend adding your vote (by selecting the Vote for this issue link) and leaving a comment to give it more weight and further express your interest.

Kind regards,
Theodora

Hi @Theodora Boudale ,

Apologies for missing that issue.

No worries Nathan, I'm glad I could point you in the right direction!

I want to share a simple python script writing by myself to control self-hosted runners with you guys. Please read the instruction on the top carefully before using it.

#!/bin/python3
"""
This script is used to control self-hosted runners. It
depends on python3.8+ and two package - docker and runlike.
I presuppose that you have no other containers' name
starting with "runner-" or you may customize this script
by yourself.

Usage: (Assuming the script is named runners.py)
./runner.py {start, stop, remove, upgrade}

Warning: When using upgrade instruction, all runners will
be deleted first and their start commands will be written
to a backup file named "runners_command_bak" storing in the
directory you current in. Once you make sure that all the
runners have started and are running normally, you can then
manually delete this file.
"""
import docker
import threading
import os
import sys
from runlike.inspector import Inspector


client = docker.from_env()
containers = client.containers.list(all=True)


def container_run(func):
threads = []
for container in containers:
if container.name.startswith("runner-"):
t = threading.Thread(
target=getattr(container, func), kwargs={"force": True} if func == "remove" else None
)
threads.append(t)
t.start()
for t in threads:
t.join()


def upgrade():
os.system("docker image pull docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1")
commands = []
for container in containers:
if container.name.startswith("runner-"):
ins = Inspector(container=container.name)
ins.inspect()
command = ins.format_cli().split(" ")
command.insert(-1, "-d")
commands.append(" ".join(command))
with open("runners_command_bak", "w") as f:
f.write("\n".join(commands))
container_run("remove")
threads = []
for command in commands:
t = threading.Thread(target=os.system, args=(command,))
threads.append(t)
t.start()
for t in threads:
t.join()


if len(sys.argv) == 1:
print("Available commands: start, stop, remove, upgrade")
sys.exit()
if sys.argv[1] in ["start", "stop", "remove"]:
container_run(sys.argv[1])
elif sys.argv[1] == "upgrade":
upgrade()
else:
raise ValueError("Invalid control parameter: "+sys.argv[1])
0 votes

I deleted the older container and then used the command instructed by Bitbucket, but I changed the tag from 1 to the latest to get the newest version of the image, and worked.

docker container rm -f container-name - to delete the container
docker rmi old-imageid - to delete the image

docker pull docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:latest - to pull the new image.

this downloads a new image, but doesn't actually update a existing runner,

To update your self-hosted runner, you must delete the repo/workspace runner and re-add it again. It will install the updated docker image.

Hi @Gino McCarty,

Are you using Windows runners or Linux runners? (or perhaps MacOS runners)?

The instructions I shared for Windows and Linux runners in my previous replies will download the newest version of the runner.

You will then need to use the pre-configured command that you were given when you created the runner (the command that starts the runner), in order to start it again.

If you didn't save that command, you will need to create a new runner and use the pre-configured command from the new runner.

However, if you have saved that command, you can use it in order to start the runner you have already been using.

Kind regards,
Theodora

We are using linux runners

I deleted the older container, but I had to preserve the initial script in code, because I had lost my original OIDC credentials, which made starting a new container not work

 

now that have that string in code its easier to do upgrades.

Like Theodora Boudale likes this

That's good to hear, thanks for the update Gino!

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events