Page MenuHomePhabricator

Allow linking to an external build system from Harbormaster
Closed, ResolvedPublic


I have Harbormaster set up to run builds on Circle CI (via excessive hacks), it'd be great to be able to click the build status link that shows on a Diff and get to the Circle CI build page.

Event Timeline

nornagon raised the priority of this task from to Needs Triage.
nornagon updated the task description. (Show Details)
nornagon added a project: Harbormaster.
nornagon added a subscriber: nornagon.

There is a URI artifact type, so if you're writing your own custom build step in PHP, you can create a URI artifact that points to the CircleCI plan:;189fb2660a905c7d683cc312af66ca2065bc51d5$16

Hi @nornagon -- would you be willing to post details of you have your "excessive hacks" configured? I would love to have a similar setup at my company.

@dpaola2 at this point I don't even remember all the things I had set up, but it involves this monstrosity running on heroku:

1var request = require('request');
2var express = require('express');
3var bodyParser = require('body-parser');
4var app = express();
5var createCanduit = require('canduit');
7app.set('port', (process.env.PORT || 5000));
9'/build', function(req, res) {
11 var target_phid =;
12 var diff_id = req.query.diff;
14 url: '',
15 qs: { "circle-token": process.env['CIRCLE_TOKEN'] },
16 json: true,
17 body: {
18 "build_parameters": {
19 "PHAB_DIFF_ID": diff_id,
20 "PHAB_TARGET_PHID": target_phid
21 }
22 }
23 }, function (err, res, body) {
24 console.log(err, body)
25 })
26 res.end();
28'/build-complete', function(req, res) {
30 var target_phid = req.body.payload.build_parameters['PHAB_TARGET_PHID'];
31 var outcome = req.body.payload.outcome
33 createCanduit({
34 api: "",
35 user: process.env['CONDUIT_USER'],
36 cert: process.env['CONDUIT_CERT'],
37 }, function(err, canduit) {
38 if (err) {
39 res.end();
40 return console.error("Error authenticating with conduit: %j", err);
41 }
42 canduit.exec('harbormaster.sendmessage', {
43 buildTargetPHID: target_phid,
44 type: (outcome == "success" ? "pass" : "fail"),
45 }, function(err, data) {
46 console.log("Called conduit", err, data)
47 res.end();
48 })
49 })
52app.listen(app.get('port'), function() {
53 console.log('Node app is running on port', app.get('port'));

epriestley triaged this task as Normal priority.Aug 10 2015, 2:41 PM
epriestley moved this task from Backlog to v2 on the Harbormaster board.

I'm going to wait until the Harbormaster doc gets split up a bit before writing details on how to use this, but here's the rough version.

After D13900 + D13903, you'll use harbormaster.createartifact(...) to publish a "uri" artifact as soon as your external build server (e.g., in Jenkins) receives a request and knows what the external build detail URI is. You'll use these parameters:

  • buildTargetPHID: The build target PHID from Phabricator, same value you're using with harbormaster.sendmessage.
  • artifactKey: Any unique name, like "jenkins.uri"
  • artifactType: The string literal "uri".
  • artifactData: A dictionary like this one:
  "uri": "",
  "name": "View Build Details in Jenkins",
  "ui.external": true

The ui.external key tells Harbormaster that this URI artifact is an external link which should be shown in the UI when build targets are rendered:

For example, this is a complete, valid call to add a link to Bing! to a build target:

$ echo '{
  "buildTargetPHID": "PHID-HMBT-bwxike43bzahut64duk5",
  "artifactKey": "",
  "artifactType": "uri",
  "artifactData": {
    "uri": "",
    "name": "Bing! It!",
    "ui.external": true
}' | arc call-conduit --conduit-uri <your-phabricator-uri> --conduit-token <conduit-token> harbormaster.createartifact

The Conduit API page for the call (/conduit/method/harbormaster.createartifact/) is greatly expanded after those changes land, too.

Overall, your Jenkins thing will look something like:

// Publish the link to the external result page.

// Run the tests.
result = run_some_tests();

// Publish the test results.

You can add several links if you want, they just each need to have unique keys (jenkins.detail-uri, jenkins.summary-uri). You should probably also give them unique names so humans can tell them apart.