File tree Expand file tree Collapse file tree 2 files changed +38
-8
lines changed
Expand file tree Collapse file tree 2 files changed +38
-8
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ sudo: false
33branches :
44 only :
55 - master
6+ - jaime/triggerci
67 - /^\d+\.\d+\.x$/ # release forked patches branch
78
89language : python
1516 - vendor/cache
1617 - $HOME/embedded
1718
18- matrix :
19- fast_finish : true
20-
2119env :
2220 global :
2321 - CONCURRENCY=2
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
3631before_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
5051after_failure :
5152 - echo "Logs from installation process come here / DEBUG LOGS"
Original file line number Diff line number Diff line change 11#!/usr/bin/env rake
22# encoding: utf-8
33# 3p
4+ require 'json'
5+ require 'net/http'
46require 'rake/clean'
57require '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
90119end
91120
92121task default : [ 'lint' , 'ci:run' ]
You can’t perform that action at this time.
0 commit comments