File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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
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
5055after_failure :
5156 - 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 )
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