Created
June 14, 2016 07:49
-
-
Save nisshiee/0a1d960b31445c731c20f18c24568953 to your computer and use it in GitHub Desktop.
AWS LambdaからCircleCI Buildをキックするスニペット
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('https') | |
exports.handler = function(event, context) { | |
var options = { | |
hostname: 'circleci.com', | |
path: '/api/v1/project/${user|org}/${project}/tree/master?circle-token=${token}', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json' | |
} | |
}; | |
var body = JSON.stringify({}); | |
var req = https.request(options, function(res) { | |
console.log('STATUS: %d', res.statusCode); | |
console.log('HEADERS: %s', JSON.stringify(res.headers)); | |
res.setEncoding('utf8'); | |
res.on('data', function(chunk) { | |
console.log('BODY: %s', chunk); | |
}); | |
res.on('end', function() { | |
console.log('No more data in response.'); | |
}); | |
}); | |
req.on('error', function(e) { | |
console.log('problem with request: %s', e.message); | |
}); | |
req.write(body); | |
req.end(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment