Search code examples
dockercontinuous-integrationtravis-cibalena

Building with balena-cli (balena build) on travis-ci


I’ve been trying to setup a CI environment on travis for my balena builds. I’ve managed to install balena-cli in travis’ environment, but cannot seem to build with a qemu environment. I’m getting this log with the --debug flag

[debug] new argv=[/home/travis/.nvm/versions/node/v12.21.0/bin/node,/home/travis/build/vivitek/deep-thought/node_modules/.bin/balena,build,--deviceType,raspberrypi3-64,--arch,aarch64,--emulated] length=8
[Debug] Parsing input...
[Debug] Loading project...
[Debug] Resolving project...
[Debug] docker-compose.yml file found at "/home/travis/build/vivitek/deep-thought"
[Debug] Creating project...
[Info] Building for aarch64/raspberrypi3-64
[Build] Building services...
[Build] dhcp Preparing...
[Build] rabbitmq Preparing...
[Build] hotspot Preparing...
[Build] pcap Preparing...
[Build] Built 4 services in 0 seconds
[Error] Build failed.
No such file or directory: /home/travis/.balena/bin
Error: ENOENT: no such file or directory, mkdir '/home/travis/.balena/bin'
For further help or support, visit:
https://www.balena.io/docs/reference/balena-cli/#support-faq-and-troubleshooting

the .travis.yml is the following:

sudo: true
language: node_js
node_js:
  - "12"
branches:
  only:
    - develop
    - master
    - ROUT-44-continuous-integration
git:
  submodules: false
cache:
  directories:
    - node_modules
before_script:
  - npm i -g balena-cli
jobs:
  include:
    - stage: "build rpi4"
      name: "Building on raspberry pi 4"
      script: ./build_rpi4.sh
    - stage: "build rpi3"
      name: "Building on raspberry pi 3"
      script: ./build_rpi3.sh

and the script buiöd_rpi4.sh is the following:

 #!/usr/bin/env sh

echo -e "Building containers in emulated containers"
balena build --deviceType raspberrypi3-64 --arch aarch64 --emulated --debug

build_rpi3.sh looks mostly the same, only the flags change.

Anyone know what might be wrong ?


Solution

  • The balena CLI will cache downloaded assets (like QEMU for --emulated) in $HOME/.balena by default, and it looks like the HOME directory doesn't exist in Travis-CI.

    You can change the balena CLI data directory by setting BALENARC_DATA_DIRECTORY in your environment first. So set it to an absolute path in your Travis workspace and I assume it will work.

    https://github.com/balena-io/balena-cli/blob/master/TROUBLESHOOTING.md#how-do-i-make-the-balena-cli-persist-data-in-another-directory