我正在使用代码气候来提高代码质量和测试覆盖率。我在 spec_helper.rb 中添加了 gem 和代码来开始覆盖。在按照文档的下一步代码中:
在 CI 上运行测试时,设置 CODECLIMATE_REPO_TOKEN 环境变量:
$CODECLIMATE_REPO_TOKEN=******************** 捆绑执行 rake
我试图在 jenkins 的执行 shell 命令中设置上面的行。还尝试在管理 jenkins -> 配置系统设置中设置环境变量 CODECLIMATE_REPO_TOKEN。但这不起作用。
我找不到任何文档来使用 jenkins 设置测试覆盖率。
任何帮助将是可观的。
根据代码气候文档
Add the codeclimate-test-reporter gem to your Gemfile:
gem "codeclimate-test-reporter", 组: :test, 要求: nil
Start the test reporter on the very first line of spec_helper.rb or test_helper.rb:
需要“codeclimate-test-reporter”
CodeClimate::TestReporter.start
When you run your tests on CI, set the CODECLIMATE_REPO_TOKEN environment variable:
$ CODECLIMATE_REPO_TOKEN=**************************** bundle exec rake
(Note: This token is specific to this repo on Code Climate.)
(Note: **As an alternative to the above, you may prefer to define this token as environment variable within your CI's user interface or configuration file**.)
它写在这里, token 环境变量将在您的 CI 服务器中定义。这就是我的问题是在 jenkins 中定义它的位置。我尝试在“管理 jenkins”->“系统配置”下的 jenkins 中定义全局环境变量。但它没有用。
最佳答案
如果您的问题是如何在 Jenkins 中设置环境变量,您可以查看例如这里:How to set environment variables in Jenkins?
关于ruby-on-rails - 如何为 jenkins CI 设置代码气候测试覆盖率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32608532/