You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让GitLab CI中的ReSharper InspectCode任务在出现警告或错误时失败?

Fixing ReSharper InspectCode to Fail CI on Warnings/Errors in GitLab

The issue you're hitting is that by default, the jb inspectcode command returns a successful exit code (0) even when it detects code issues—that’s why your GitLab CI job keeps passing regardless of warnings or errors. To make the job fail when problems are found, you need to add specific flags that tell InspectCode to return a non-zero exit code when issues of a certain severity are detected.

Here's how to update your .gitlab-ci.yml configuration to achieve this:

inspect:
  stage: inspectcode
  script: 
    - "jb inspectcode MySln.sln -o=report.xml --fail-severity=WARNING"
  artifacts:
    paths:
      - report.xml

Key Details About the Flag:

  • --fail-severity=WARNING: This flag tells InspectCode to fail (return a non-zero exit code) if it finds any issues with severity WARNING or higher (including ERROR-level problems). This ensures both warnings and errors will trigger a CI job failure.
  • If you only want the job to fail on ERROR-level issues (and ignore warnings), replace the flag with --fail-severity=ERROR.
  • You can also use the shorthand --fail-on-warnings as an alternative to --fail-severity=WARNING—they function identically.

Optional: Fine-Tune with a Custom Inspection Profile

If you need tighter control over which specific rules should block the pipeline, you can create a custom ReSharper inspection profile (saved as a .DotSettings file) and reference it with the --profile flag:

inspect:
  stage: inspectcode
  script: 
    - "jb inspectcode MySln.sln -o=report.xml --fail-severity=WARNING --profile=MyCustomRules.DotSettings"
  artifacts:
    paths:
      - report.xml

This lets you enforce exactly which code quality standards are critical enough to stop your CI pipeline.

内容的提问来源于stack exchange,提问作者Nikita Burmistrov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 08:57:45