如何为jenkins CI设置代码气候测试覆盖率

Aje*_*han 6 ruby-on-rails jenkins code-climate

我正在使用代码环境来实现代码质量和测试覆盖率.我在spec_helper.rb中添加了gem和代码来启动覆盖.在下一步中,根据文档编写代码:在CI上运行测试时,设置CODECLIMATE_REPO_TOKEN环境变量:$ CODECLIMATE_REPO_TOKEN =********************bundle exec rake

我试图在jenkins的execute shell命令中设置上面的行.还尝试在Manage jenkins - > Configure System设置中设置环境变量CODECLIMATE_REPO_TOKEN.但这不起作用.我找不到任何用jenkins设置测试覆盖率的文档.任何帮助都会很明显.

根据代码 - 气候文档

Add the codeclimate-test-reporter gem to your Gemfile:
Run Code Online (Sandbox Code Playgroud)

gem"codeclimate-test-reporter",group :: test,require:nil

Start the test reporter on the very first line of spec_helper.rb or test_helper.rb:
Run Code Online (Sandbox Code Playgroud)

需要"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**.) 
Run Code Online (Sandbox Code Playgroud)

在此处写入令牌环境变量将在CI服务器中定义.这就是我的问题是在jenkins中定义它的位置.我尝试在"管理jenkins" - >"系统配置"下的jenkins中定义全局环境变量.但它没有用.

在此输入图像描述

The*_*ent 1

如果您的问题是如何在 Jenkins 中设置环境变量,您可以在这里查看:如何在 Jenkins 中设置环境变量?