Skip to main content

Raspberry Pi Example

Now we can try running an example that uses an external device: A Raspberry Pi. We will get the Raspberry Pi to print Hello World.

Creating our git repo

Before you can create a pipeline, you need to create a code repository that will form the code base of the pipeline:

  1. Create a new folder called .bbx in a Github code repository.
  2. Create a file called config.yaml in the folder you just created and copy in the following code:
runners:
local-runner:
image: public.ecr.aws/y2s4f3y9/ubuntu-generic:latest
jobs:
pi-hello-world:
resource_spec: small
runner: local-runner
current_working_directory: ~/
device: raspberry-pi
steps:
- run:
name: Setup
command: apt-get install sshpass
- run:
name: Run device
on-device: True
command: |
echo Hello World
workflows:
pi-hello-world-workflow:
jobs:
- pi-hello-world
  1. Create a Device record on BeetleboxCI using the following YAML code (amend the IP address 192.168.1.92 as necessary to the IP address of your own Raspberry Pi device):
devices:
raspberry-pi:
connection: sshpass -p raspberry ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" pi@192.168.1.92
prompt: "#"
status:
setup: |
apt-get install sshpass -y >/dev/null 2>&1

command:
bash -c 'echo Hello World'
pass:
"Hello World"

Create pipeline

Now you have created your code repository, it is time to create a pipeline.

To proceed, please perform the following steps:

  1. Click 'Create pipeline'
  2. In the following screen, fill in the following:
  • Pipeline Name: pi-hello-world

  • Repository URL: https://github.com/<username/>/<repo_name/>

  • Authentication Settings — Username: <The_name_of your_git_account/>

  • Authentication Settings — Password: <Github_personal_access_token/>

    If you created your repository with public access, then the authentication information will not be necessary. Note that Github no longer supports password authentication for cloning repositories, so a personal access token is required. If you do not already have a personal access token for Github, you can follow this link from Github which shows how to create one.

    As an alternative to your username and a personal access token, you can generate an SSH key to authenticate access to private git repositories (given that the public key is added either to your Github account or just as a deploy key to the repository). More information on this can be found in the VCS Integration section.

  1. Click proceed. You will now be redirected to the pipelines page where you can see the pipeline that you just created.
  2. On the pipelines page, click pi-hello-world so see the workflows in this pipeline
  3. Click the run button on the top right hand corner of the workflows list. The pipeline will begin running and it should take around 30 seconds to complete.
  4. You will see Passed on the pi-hello-world pipeline once it has completed.

Viewing our output

  1. You can also check our logs to make sure the output is correct. To do this, click on the pipeline name pi-hello-world.

pihelloworldpipeline

  1. In this page you will be able to view the workflows of the pi-hello-world pipeline. There will be a single workflow named pi-hello-world-workflow, which will take us to the jobs that make up that workflow.

pihelloworldworkflow

  1. In the jobs page, you may view the jobs that are used in the pi-hello-world-workflow. Click on the job name pi-hello-world

pihellworldjob

  1. From here, you will be able to view details about the job, including an overview of its status as well as logs and artifacts generated by this job.

pihelloworldjobdetail

  1. By checking out the Log, you can see the generated logs by the job. In this case, you will be able to see that the job has successfully outputted the Hello World message.

pihelloworldjoblog

Congratulations you have run your first pipeline!

What's next?