diff --git a/.travis.yml b/.travis.yml index 2aaa186f0a..d9dcbd1d4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,6 @@ cache: - vendor/cache - $HOME/embedded -matrix: - fast_finish: true - env: global: - CONCURRENCY=2 @@ -26,11 +23,8 @@ env: - PIP_CACHE=$HOME/.cache/pip - VOLATILE_DIR=/tmp - DD_CASHER_DIR=/tmp/casher + - secure: cljGaYMtRkLuW1xjGyF8W0ACrkBwHQTGJUaEoqxtIEJaVjLwcuznny9qzuQvF8YJhjs7g9eRAsZqWGpgRw765rzUB5C4Cp5GpUdTHS/fPINj3AXRzGztL2m6DHBidjEyYaX8dryO4xR0uCULwp4bSI0Rht71VqE90/6z1ehIzBs= matrix: - - TRAVIS_FLAVOR=default - - TRAVIS_FLAVOR=core_integration - - TRAVIS_FLAVOR=checks_mock - - TRAVIS_FLAVOR=system # Override travis defaults with empty jobs before_install: echo "OVERRIDING TRAVIS STEPS" @@ -43,9 +37,15 @@ script: # Needed if no cache exists - mkdir -p $INTEGRATIONS_DIR - ls -al $INTEGRATIONS_DIR - - 'rake ci:run' + - 'rake ci:run[default]' + - 'rake ci:run[core_integration]' + - 'rake ci:run[checks_mock]' + - 'rake ci:run[system]' - ls -al $INTEGRATIONS_DIR +after_success: + - 'rake ci:trigger[integrations-core]' + - 'rake ci:trigger[integrations-extras]' after_failure: - echo "Logs from installation process come here / DEBUG LOGS" diff --git a/Rakefile b/Rakefile index cc3b674e4d..8d558bd749 100755 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ #!/usr/bin/env rake # encoding: utf-8 # 3p +require 'json' +require 'net/http' require 'rake/clean' require 'rubocop/rake_task' @@ -87,6 +89,33 @@ namespace :ci do flavors = flavor.split(',') flavors.each { |f| Rake::Task["ci:#{f}:execute"].invoke } end + + desc 'Trigger remote CI' + task :trigger, :repo do |_, args| + abort 'Task only applies to travis builds.' if !ENV['TRAVIS'] || !ENV['TRAVIS_API_TOKEN'] + repo = "DataDog%2F#{args[:repo]}" + url = "https://api.travis-ci.org/repo/#{repo}/requests" + body = { 'request' => { 'branch' => 'master' } }.to_json + + uri = URI(url) + res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| + req = Net::HTTP::Post.new(uri.path) + req['Content-Type'] = 'application/json' + req['Accept'] = 'application/json' + req['Travis-API-Version'] = '3' + req['Authorization'] = "token #{ENV['TRAVIS_API_TOKEN']}" + # The body needs to be a JSON string, use whatever you know to parse Hash to JSON + req.body = body + http.request(req) + end + + case res + when Net::HTTPSuccess then + puts "Build Triggered remotely for: #{url}" + else + puts "Error triggering build (error #{res.code}): #{url}" + end + end end task default: ['lint', 'ci:run']