在 travis-ci 上使用 balena-cli (balena build) 构建

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

我一直在尝试在 travis 上为我的 balena 构建设置一个 CI 环境。我已经设法在 travis 的环境中安装了 balena-cli,但似乎无法使用 qemu 环境进行构建。我正在使用 --debug 标志

获取此日志
[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

.travis.yml 如下:

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

脚本 buiöd_rpi4.sh 如下:

 #!/usr/bin/env sh

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

build_rpi3.sh 看起来大体相同,只是标志发生了变化。

有人知道哪里出了问题吗?

默认情况下,balena CLI 会在 $HOME/.balena 中缓存下载的资产(如 --emulated 的 QEMU),而且 HOME 目录似乎在 Travis 中不存在-CI .

您可以先在您的环境中设置 BALENARC_DATA_DIRECTORY 来更改 balena CLI 数据目录。因此,将其设置为您的 Travis 工作区中的绝对路径,我认为它会起作用。

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