gitlab ci/cd-向gitlab UI发送评论/警报?
目前,我在.gitlab-ci.yml文件中有此行:
if (( $coverage < $MIN_COVERAGE )) ; then echo "$coverage% of code coverage below threshold of $MIN_COVERAGE%" && exit 1 ; else exit 0 ; fi
$ coverage
是代码的测试覆盖范围,用pytest-cov
$ min_coverage
是指定的最小值$覆盖范围的测试覆盖率水平不应下降到
当前,这会导致管道失败,例如,覆盖范围为70%并且MIN_COVERAGE为80%。一条消息还打印到终端:“ $ coverage%的代码覆盖范围低于$ min_coverage%的阈值””
但是,此消息仅显示在Gitlab作业的终端中,因此,如果有人想查看为什么以及他们的多少管道失败了,他们需要进入工作终端并查看输出。
与其对工作终端的回声,还可以使此消息在Gitlab UI上的某个地方输出吗?
Currently I have this line in my .gitlab-ci.yml file:
if (( $coverage < $MIN_COVERAGE )) ; then echo "$coverage% of code coverage below threshold of $MIN_COVERAGE%" && exit 1 ; else exit 0 ; fi
$coverage
is the test coverage of the code, determined with pytest-cov
$MIN_COVERAGE
is a specified minimum level of test coverage which $coverage shouldn't drop below
Currently, this causes the pipeline to fail if, for instance, coverage is 70% and min_coverage is 80%. A message is also printed to the terminal: "$coverage% of code coverage below threshold of $MIN_COVERAGE%"
However, this message is only displayed in the terminal of the gitlab job, so if someone wanted to see why and by how much their pipeline failed they would need to go into the job terminal and look at the output.
Instead of having this echo to the job terminal, is there a way to get this message to output somewhere on the gitlab UI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是使用GitLab API创建新的合并请求注/评论的方法。
Here's how to create a new Merge Request Note/Comment using the GitLab API.
此外,您可以使用 gitlab cli tool (
glab
)在您的CI管道中:In addition, you can use the GitLab CLI tool (
glab
) in your CI pipeline:如果您有Gitlab Premium订阅或更高的订阅,则可以使用 noreferrer“>量表报告在MR UI中揭示所有指标,包括覆盖率百分比。
在Gitlab的所有层中, noreflow noreferrer“> cosevelization> cosevaleing 也可用但是我尚不清楚这是否显示整体覆盖范围百分比。
另外,您可以使用API 到合并请求(您可以从作业中的预定义变量中获取MR ID)。但是,您需要为CI工作提供API令牌 - 您不能使用内置的作业令牌来添加评论。
If you have a GitLab Premium subscription or higher, you can use metrics reports to expose any metric, including coverage percentage, in the MR UI.
In all tiers of GitLab, coverage visualization is also available, but it's unclear to me if this displays the overall coverage percentage.
Alternatively, you can use the API to add comments to the merge request (you can get the MR ID from predefined variables in the job). However, you will need to supply an API token to the CI job -- you cannot use the builtin job token to add comments.