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

Use local devices on self hosted runners

Thomas Augustin August 23, 2021

Hello,

 

I am kind of new to docker and and  to self-hosted runners in bitbucket as well.

I am trying to access a local USB device via a self hosted pipeline runner on a local host PC.

It tried to add 

-t -i --device=/dev/ttyUSB0:/dev/ttyUSB0

to the command to start the local runner on the host PC.

 

And I also tried to added the devices in the .yml file in bitbucket like: 

image: ubuntu

devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"

pipelines:
default:
- step:
name: Run unittests on local host
runs-on:
- 'self.hosted'
script:
- echo "This step will run on a self hosted runner.";
- ls /dev/

 

Unfortunately, I am not able to see the USB devices either way.

 

Is it possible to access or connect to the local USB devices?

If it is possible, how should I do it?

2 answers

0 votes
Théo Meyer September 9, 2021

Device access or even full host access (file system + device) would open an important amount of possibility for automation of test on real devices.

@Thomas Augustin how did you achieve that using SSH? You ssh from the docker to the runner host ?

0 votes
Michael Wurm August 24, 2021

+1 for that!

I would really like to see this feature too!  

 

Simply allowing the 'privileged mode' for the Docker image would resolve any issues.

This feature was already requested here: https://jira.atlassian.com/browse/BCLOUD-13420

 

Back then, the privileged mode was not supported, because of security reasons.

However, now that local self-hosted runners are available, it should be one's own decision to run the pipeline in privileged mode!

 

A common use case that requires access to local USB devices:
Development and testing of an embedded device.
Using a programmer to flash i.e. a microcontroller is almost always done through USB!

Thomas Augustin August 27, 2021

Thanks for the kind answer,

I realized in the meantime, that both ways are not working because when I start the local runner by 

-t -i --device=/dev/ttyUSB0:/dev/ttyUSB0

it only starts the runner with that the usb devices however not the container which is started by the runner.

 

And the other way does not work because bitbucket pipeline does support that option.

 

I solved that issue by using ssh to access the local host pc via the pipeline container and from there I have access to the USB devices. Feels like a detour, but at least I can use the pipeline now to test the embedded device.

Like Michael Wurm likes this
Jarek Piotrowiak January 10, 2022

+1 from me. I could really use this feature for testing embedded system

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events