Gitlab-CI:有条件的allow_failure [英] Gitlab-CI: conditional allow_failure

查看:149
本文介绍了Gitlab-CI:有条件的allow_failure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始为我的代码实现自动测试,我注意到CI不会捕获编译器的警告-即使有警告,测试也显示为成功.我最初为编译器添加了一个标志,以将警告变为错误和 allow_failure = True ,但是问题是,编译器在第一个警告->错误中停止并且没有遍历整个汇编.然后,我使用了

请参见文档here to write the warnings into a file, and then test if the file is not zero:

    - make 2> >(tee make.warnings)
    - test ! -s make.warnings

After the whole compilation is done, this will give an error if there are warnings written to the file - and using allow_failure=True, this works for the cases where I have no errors/warnings, but also when I have warnings. However, if I have real errors, this will also be shown as a warning in CI, and will not stop the pipeline because of the allow_failure=True.

I could not find a way to allow_failure=True depending on something run in the script (without creating a new stage) or using some condition (i.e., if the file is empty or not). Is there a simple way to do this that I'm missing?

解决方案

Since there is no condition per se, check out GitLab 13.8 (January 2021):

Control job status using exit codes

You can use the allow_failure keyword to prevent failed jobs from causing an entire pipeline to fail.

Previously, allow_failure only accepted boolean values of true or false but we’ve made improvements in this release.

Now you can use the allow_failure keyword to look for specific script exit codes.

This gives you more flexibility and control over your pipelines, preventing failures based on the exit codes.

See Documentation and Issue.

If you can use as condition an exit status of a script, that would be enough for allow_failure to be more specific.

这篇关于Gitlab-CI:有条件的allow_failure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆