Skip to main content

Using Knapsack Pro with CircleCI

Collect metadata in Queue Mode

You may want to collect metadata in CircleCI. For example, to collect junit reports of your RSpec runs you would:

spec_helper.rb or rails_helper.rb
# `TMP_REPORT` must be the same path as `--out`
# `TMP_REPORT` must be a full path (no `~`)
TMP_REPORT = "tmp/tmp_rspec_#{ENV['KNAPSACK_PRO_CI_NODE_INDEX']}.xml"
FINAL_REPORT = "tmp/final_rspec_#{ENV['KNAPSACK_PRO_CI_NODE_INDEX']}.xml"

KnapsackPro::Hooks::Queue.after_subset_queue do |queue_id, subset_queue_id|
if File.exist?(TMP_REPORT)
FileUtils.mv(TMP_REPORT, FINAL_REPORT)
end
end

KnapsackPro::Hooks::Queue.after_queue do |queue_id|
if File.exist?(FINAL_REPORT) && ENV['CIRCLE_TEST_REPORTS']
FileUtils.cp(FINAL_REPORT, "#{ENV['CIRCLE_TEST_REPORTS']}/rspec.xml")
end
end

You can find a complete CircleCI configuration in RSpec testing parallel jobs with CircleCI and JUnit XML report.

This site uses cookies. By staying here you accept them. See our Cookie Policy for details.
For more information on how to turn off the use of cookies, please see this.
To refuse the use of cookies, please leave the page (more details here).