首页 > 解决方案 > Gitlab CI 和 matlab

问题描述

我正在尝试为我在 gitlab 上的相当大的 Matlab 代码设置一些测试。

我创建了 .gitlab-ci.yml 文件,该文件启动一个 bash 脚本,然后调用 matlab。

#.gitlab-ci.yml

before_script:

Test:
  script:
    - chmod +x RunTests.sh
    - ./RunTests.sh

bash 脚本如下:

# RunTests.sh
cd IntegratedTests

LOGFILE=log.txt

matlab -nodesktop -nosplash -minimize -wait -logfile "$LOGFILE" -r 'RunTests';
CODE=$?

cat "$LOGFILE"

exit $CODE

但是,gitlab 尝试使用共享的 gitlab-runner,它使用来自 ruby​​ 的 docker 映像。测试最终失败,因为它在 docker-image 上找不到 matlab。

Running with gitlab-runner 12.0.0-rc1 (58d8360f)
  on docker-auto-scale ed2dce3a
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:80f53b90f8657c63c8d35d5eff399e6410baf19013c3b4c1c4158b2029060147 for ruby:2.5 ...
Running on runner-ed2dce3a-project-11747478-concurrent-0 via runner-ed2dce3a-srm-1561674473-a1c90512...
Fetching changes...
Initialized empty Git repository in /builds/darsim2simulator/darsim2/.git/
Created fresh repository.
From https://gitlab.com/darsim2simulator/darsim2
 * [new branch]      3-fixed-time-step-size -> origin/3-fixed-time-step-size
 * [new branch]      4-single-temperature-formulation-for-geothermal -> origin/4-single-temperature-formulation-for-geothermal
 * [new branch]      FIMLTS                 -> origin/FIMLTS
 * [new branch]      master                 -> origin/master
 * [new branch]      patch-1                -> origin/patch-1
 * [new branch]      patch-2                -> origin/patch-2
 * [new branch]      patch-3                -> origin/patch-3
Checking out ff3f0a4f as master...

Skipping Git submodules setup
$ chmod +x RunTests.sh
$ ./RunTests.sh
./RunTests.sh: line 6: matlab: command not found
cat: log.txt: No such file or directory
ERROR: Job failed: exit code 1

我猜问题是docker-image上没有安装matlab

这是我第一次使用 gilab CI,所以我可能没有正确理解如何使用它,但我的替代方案是什么?如何设置具有 matlab 的跑步者?

标签: matlabgitlab-cigitlab-ci-runner

解决方案


对于我们项目中的特定跑步者,我在.gitlab-ci.yml

就像是:

Test:
  script:
    - chmod +x RunTests.sh
    - ./RunTests.sh
  tags:
    - runners-tag

更多信息在

https://docs.gitlab.com/ee/ci/yaml/#tags


推荐阅读