Page MenuHomePhabricator

circle-phab-glue.js

Authored By
nornagon
Jul 24 2015, 6:19 AM
Size
1 KB
Referenced Files
None
Subscribers
None

circle-phab-glue.js

var request = require('request');
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var createCanduit = require('canduit');
app.set('port', (process.env.PORT || 5000));
app.use(bodyParser.json())
app.post('/build', function(req, res) {
var target_phid = req.query.target;
var diff_id = req.query.diff;
request.post({
url: 'https://circleci.com/api/v1/project/transcriptic/www/tree/circle',
qs: { "circle-token": process.env['CIRCLE_TOKEN'] },
json: true,
body: {
"build_parameters": {
"PHAB_DIFF_ID": diff_id,
"PHAB_TARGET_PHID": target_phid
}
}
}, function (err, res, body) {
console.log(err, body)
})
res.end();
});
app.post('/build-complete', function(req, res) {
var target_phid = req.body.payload.build_parameters['PHAB_TARGET_PHID'];
var outcome = req.body.payload.outcome
createCanduit({
api: "https://work.r23s.net/api/",
user: process.env['CONDUIT_USER'],
cert: process.env['CONDUIT_CERT'],
}, function(err, canduit) {
if (err) {
res.end();
return console.error("Error authenticating with conduit: %j", err);
}
canduit.exec('harbormaster.sendmessage', {
buildTargetPHID: target_phid,
type: (outcome == "success" ? "pass" : "fail"),
}, function(err, data) {
console.log("Called conduit", err, data)
res.end();
})
})
})
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/im/ed/ozatf65tzifysyyo
Default Alt Text
circle-phab-glue.js (1 KB)

Event Timeline