Skip to content

Commit 745aafa

Browse files
committed
[travis][ci] launch core and extras if merge successful
[rakefile] fix repo names. [travis] can we do without the matrix. [travis] use uri path to create post object.
1 parent b74d12f commit 745aafa

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

.travis.yml

Lines changed: 9 additions & 8 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
@@ -15,9 +16,6 @@ cache:
1516
- vendor/cache
1617
- $HOME/embedded
1718

18-
matrix:
19-
fast_finish: true
20-
2119
env:
2220
global:
2321
- CONCURRENCY=2
@@ -26,11 +24,8 @@ env:
2624
- PIP_CACHE=$HOME/.cache/pip
2725
- VOLATILE_DIR=/tmp
2826
- DD_CASHER_DIR=/tmp/casher
27+
- secure: cljGaYMtRkLuW1xjGyF8W0ACrkBwHQTGJUaEoqxtIEJaVjLwcuznny9qzuQvF8YJhjs7g9eRAsZqWGpgRw765rzUB5C4Cp5GpUdTHS/fPINj3AXRzGztL2m6DHBidjEyYaX8dryO4xR0uCULwp4bSI0Rht71VqE90/6z1ehIzBs=
2928
matrix:
30-
- TRAVIS_FLAVOR=default
31-
- TRAVIS_FLAVOR=core_integration
32-
- TRAVIS_FLAVOR=checks_mock
33-
- TRAVIS_FLAVOR=system
3429

3530
# Override travis defaults with empty jobs
3631
before_install: echo "OVERRIDING TRAVIS STEPS"
@@ -43,9 +38,15 @@ script:
4338
# Needed if no cache exists
4439
- mkdir -p $INTEGRATIONS_DIR
4540
- ls -al $INTEGRATIONS_DIR
46-
- 'rake ci:run'
41+
- 'rake ci:run[default]'
42+
- 'rake ci:run[core_integration]'
43+
- 'rake ci:run[checks_mock]'
44+
- 'rake ci:run[system]'
4745
- ls -al $INTEGRATIONS_DIR
4846

47+
after_success:
48+
- 'rake ci:trigger[integrations-core]'
49+
- 'rake ci:trigger[integrations-extras]'
4950

5051
after_failure:
5152
- 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.path)
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)