0 Preface/Foreword
1 GitLab runner环境
具体情况如下:
- Gitlab-ruuner运行在wsl 1中的++Ubuntu 18.04++ distro上
- 专门为GitLab-runner分配了一个用户,名为++gitlab-runner++


2 自动编译
2.1 Permission denied

编译过程中,有两个文件出现权限不允许情况,一个是dsp/build.sh 文件,一个是mcu/build.sh文件。
++解决方法:++
- 运行过程中通过chmod命令修改文件权限
- 修改gitlab repo 中文件权限,使用命令++git update-index --chmod=+x FileName++


2.1.1 解决办法
修改仓库中文件权限。(可以通过脚本,一次性将所有的*.sh文件权限修改成可执行)
find ./ -name "*.sh" | xargs git update-index --chmod=+x



2.2 删除文件失败
第二次触发gitlab-runner时,会出现删除out/权限不够。
2.2.1 解决办法
在job完成之后,清除out/。
sudo rm -rf ./out


2.3 编译工具链不正确
2.1和2.2中的问题解决后,出现了新的问题,最终编译还是失败,DSP 和MCU都没有编译通过。
2.3.1 DSP编译失败
失败案例中关键LOG:

成功案例中关键LOG:

开发环境搭建时候,编译工具链是安装在: /home/andy/airoha_sdk_toolchain 路径下。
2.3.2 MCU编译失败
失败案例LOG:
成功案例LOG:

2.4 解决工具链问题
2.4.1 MCU工具链
因为gitlab-runner instance使用的是用户gitlab-runner,而不是博主默认用户andy,Airoha的编译工具链安装,没有把安装路径暴露给环境变量PATH,并且工具安装时是使用andy用户安装。
尝试过的验证:
- 在gitlab-runner主目录下,用andy用户,编译工程,DSP & MCU都失败;
- 将gitlab-runner主目录下的项目,拷贝到andy的目录下,DSP&MCU编译成功;
- CI/CD yml,中,参考第二个实验的方式,DSP编译失败,MCU编译成功。DSP编译失败的原因,编译工具链路径不正确。
以下为第3个实验修改和编译结果:



2.4.2 DSP工具链
根据2.4.1可知道,切换项目build路径,MCU的工具链使用正确,但是DSP的工具链(是不是跟License有关?不确定???)还是不正确,那么只剩下一种可能,用户使用不当。
++解决方法:++
- gitlab-runner服务安装时候,指定用户为Ubuntu distro默认用户,即andy。(为了消除其他因素干扰,uninstall Ubuntu distro,然后re-install Ubuntu distro。)
- 指定andy为gilab-runner service用户方法为,sudo gitlab-runner install --user=andy --working-directory=/home/andy
Please see the below screenshot in more detail:





++NOTE:++
- 编译完成后,生成的目标文件approximate 400M bytes (0.4 G)
- 整个编译时间approximate 2 mins (1min45s).
2.5 Miscellaneous (杂项)
2.5.1 gitlab-runner中下载的项目copy到其他文件夹
gitlab-runner中下载的项目:/home/andy/builds/VhvsZA15/0/Solgaard/Headphones/AB1571AM-Firmware (++提交代码后,触发gitlab-runner,自动下载项目代码++)
++正常编译的路径++:
- /mnt/c/
- /mnt/d/
++编译失败路径++:
- /home/andy/Airoha_dev_env_setup (该路径也不能正常编译MCU,与预期有出入。/home/andy/Airoha_dev_env_setup/bta_sdk,默认的实例代码可以编译成功)
- /home/andy/
- /home/
- /mnt/
- /mnt/wsl/
2.5.2 d盘git clone下载下来的代码拷贝到其他文件夹
所有路径都能编译。
3 CI/CD yml异常汇总
3.1 打包文件失败
WARNING: out: no matching files. Ensure that theartifact path is relative to the working directory.

3.2 自定义包名替代异常
WARNING: invalid artifact name: unexpected command substitution at 1:20

++yml配置++:

++包名++:_CI_PROJECT_NAME-cat___BUILD_VERSION_FILENAME.zip
