Skip to content

Instantly share code, notes, and snippets.

@oisin
Created September 18, 2012 06:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oisin/3741569 to your computer and use it in GitHub Desktop.
Save oisin/3741569 to your computer and use it in GitHub Desktop.
CircleCI coverage retrieval - Rake task to email coverage figures and CircleCI config to trigger post-build
test:
post:
- bundle exec rake email_coverage:
require 'pony'
require 'zip/zip'
desc "Email the coverage to someone who gives a damn"
task :email_coverage do
archive = "test-coverage.zip"
Zip::ZipFile.open(archive, 'w') do |zipfile|
Dir["coverage/**/**"].reject{ |f| f == archive}.each do |file|
zipfile.add(file.sub('coverage/',''),file)
end
end
Pony.mail({
:to => "buildboss@yourdomain.com",
:from => "ci@yourdomain.com",
:subject => "Coverage for latest CircleCI build",
:body => "Ermahgerd kerverage. Unzip the attachment and load test-coverage/index.html to read.",
:attachments => {"test-coverage.zip" => File.read(archive)},
:via => :smtp,
:via_options => {
:address => 'smtp.sendgrid.net',
:port => '587',
:domain => 'yourdomain.com',
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment