diff options
| author | Guillaume Grossetie <ggrossetie@gmail.com> | 2017-07-09 11:08:43 +0200 |
|---|---|---|
| committer | Guillaume Grossetie <ggrossetie@gmail.com> | 2017-07-09 11:08:43 +0200 |
| commit | 54ff935954ccbddba1b3739f40a1196ae0edffff (patch) | |
| tree | bbed6642b7957eb748591a40b857b94ed0e4427c /Rakefile | |
| parent | fb5bea39dfcdd4cc975199845524be0a8a16b4d8 (diff) | |
Adds a Rake task to trigger build on dependent projects
Diffstat (limited to 'Rakefile')
| -rw-r--r-- | Rakefile | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -126,3 +126,38 @@ desc 'Open an irb session preloaded with this library' task :console do sh 'bundle console', :verbose => false end + +desc 'Trigger a build on Travis for all dependent projects' +task :build_dependent_projects do + require 'net/http' + require 'uri' + require 'json' + + projects = [ + { :org => "asciidoctor", :name => "asciidoctor.js", :token => "#{ENV['ASCIIDOCTOR_JS_TRAVIS_TOKEN']}" } + ] + for project in projects + uri = URI.parse("https://api.travis-ci.org/repo/#{project[:org]}%2F#{project[:name]}/requests") + header = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Travis-API-Version': '3', + 'Authorization': "token #{project[:token]}" + } + user = { + request: { + branch: 'master' + } + } + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + request = Net::HTTP::Post.new(uri.request_uri, header) + request.body = user.to_json + response = http.request(request) + if response.code == '200' + p "Build successfuly triggered on #{project[:name]}" + else + abort("Unable to build #{project[:name]}, #{response.code} - #{response.message}") + end + end +end |
