Skip to content

Commit 3e95347

Browse files
committed
[travis][ci] launch core and extras if merge successful
[rakefile] fix repo names.
1 parent b74d12f commit 3e95347

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ sudo: false
33
branches:
44
only:
55
- master
6+
- jaime/triggerci
67
- /^\d+\.\d+\.x$/ # release forked patches branch
78

89
language: python
@@ -26,6 +27,7 @@ env:
2627
- PIP_CACHE=$HOME/.cache/pip
2728
- VOLATILE_DIR=/tmp
2829
- DD_CASHER_DIR=/tmp/casher
30+
- secure: cljGaYMtRkLuW1xjGyF8W0ACrkBwHQTGJUaEoqxtIEJaVjLwcuznny9qzuQvF8YJhjs7g9eRAsZqWGpgRw765rzUB5C4Cp5GpUdTHS/fPINj3AXRzGztL2m6DHBidjEyYaX8dryO4xR0uCULwp4bSI0Rht71VqE90/6z1ehIzBs=
2931
matrix:
3032
- TRAVIS_FLAVOR=default
3133
- TRAVIS_FLAVOR=core_integration
@@ -46,6 +48,9 @@ script:
4648
- 'rake ci:run'
4749
- ls -al $INTEGRATIONS_DIR
4850

51+
after_success:
52+
- 'rake ci:trigger[integrations-core]'
53+
- 'rake ci:trigger[integrations-extras]'
4954

5055
after_failure:
5156
- echo "Logs from installation process come here / DEBUG LOGS"

Rakefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env rake
22
# encoding: utf-8
33
# 3p
4+
require 'json'
5+
require 'net/http'
46
require 'rake/clean'
57
require 'rubocop/rake_task'
68

@@ -87,6 +89,33 @@ namespace :ci do
8789
flavors = flavor.split(',')
8890
flavors.each { |f| Rake::Task["ci:#{f}:execute"].invoke }
8991
end
92+
93+
desc 'Trigger remote CI'
94+
task :trigger, :repo do |_, args|
95+
abort 'Task only applies to travis builds.' if !ENV['TRAVIS'] || !ENV['TRAVIS_API_TOKEN']
96+
repo = "DataDog%2F#{args[:repo]}"
97+
url = "https://api.travis-ci.org/repo/#{repo}/requests"
98+
body = { 'request' => { 'branch' => 'master' } }.to_json
99+
100+
uri = URI(url)
101+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
102+
req = Net::HTTP::Post.new(uri)
103+
req['Content-Type'] = 'application/json'
104+
req['Accept'] = 'application/json'
105+
req['Travis-API-Version'] = '3'
106+
req['Authorization'] = "token #{ENV['TRAVIS_API_TOKEN']}"
107+
# The body needs to be a JSON string, use whatever you know to parse Hash to JSON
108+
req.body = body
109+
http.request(req)
110+
end
111+
112+
case res
113+
when Net::HTTPSuccess then
114+
puts "Build Triggered remotely for: #{url}"
115+
else
116+
puts "Error triggering build (error #{res.code}): #{url}"
117+
end
118+
end
90119
end
91120

92121
task default: ['lint', 'ci:run']

0 commit comments

Comments
 (0)