我让gitlab CI正在运行以测试一些脚本,并且我使用.gitlab-ci.yml的以下行来显示MATLAB构建的输出:
before_script:
test1:
script:
- matlab -nosplash -nodesktop -minimize -wait -logfile matlab-output.txt -r Model
- type matlab-output.txt
当构建成功时,这完美地起作用,但是当构建失败时则不是这样,因为第二条命令未运行。我检查了gitlab-ci-runner,它没有“ after_script”选项。您如何解决这个问题?
注意:这是Windows。
很抱歉耽搁了很长时间,感谢其他所有人的帮助。我现在有一个使用Suever代码的正在运行的系统。我已对其进行修改以适合MATLAB的Unit框架。
所以,最后我的.gitlab-ci.yml是:
before_script:
Model-01:
script:
- cd developers\testModel\01
- Gitlab_CI_Hook.cmd
Model-02:
script:
- cd developers\testModel\02
- Gitlab_CI_Hook.cmd
其中Gitlab_CI_Hook.cmd为:
matlab -nosplash -nodesktop -minimize -wait -logfile matlab-output.txt -r Git_MATLAB_interface
type matlab-output.txt
set content=
for /f "delims=" %%i in (ExitCode.txt) do set content=%content% %%i
exit %content%
和Git_MATLAB_interface.m
% assume it always fails
exit_code = 1;
% MATLAB runs the test
result = runtests(pwd)
% check the result
if result.Passed ~= 0 && result.Failed == 0 && result.Incomplete == 0
exit_code = 0;
end
% write the ExitCode
fid = fopen('ExitCode.txt','w');
fprintf(fid,'%d',exit_code);
fclose(fid);
% Ensure that we ALWAYS call exit that is always a success so that CI doesn't stop
exit
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句