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:
- Create a new folder called
.bbxin a Github code repository.
- Create a file called
config.yamlin the folder you just created and copy in the following code:
command: apt-get install sshpass
name: Run device
echo Hello World
- 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):
connection: sshpass -p raspberry ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" email@example.com
apt-get install sshpass -y >/dev/null 2>&1
bash -c 'echo Hello World'
Now you have created your code repository, it is time to create a pipeline.
To proceed, please perform the following steps:
- Click 'Create pipeline'
- 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.
- Click proceed. You will now be redirected to the pipelines page where you can see the pipeline that you just created.
- On the pipelines page, click pi-hello-world so see the workflows in this pipeline
- 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.
- You will see "Passed" on the pi-hello-world pipeline once it has completed.
Viewing our output
- You can also check our logs to make sure the output is correct. To do this, click on the pipeline name
- In this page you will be able to view the workflows of the
pi-hello-worldpipeline. There will be a single workflow named
pi-hello-world-workflow, which will take us to the jobs that make up that workflow.
- In the jobs page, you may view the jobs that are used in the
pi-hello-world-workflow. Click on the job name
- 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.
- 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
Congratulations you have run your first pipeline!