Skip to content

Instantly share code, notes, and snippets.

@Firehed
Last active December 20, 2015 09:49
Show Gist options
  • Save Firehed/6111019 to your computer and use it in GitHub Desktop.
Save Firehed/6111019 to your computer and use it in GitHub Desktop.
Jenkins/Phabricator integration scripts
#!/usr/bin/php
<?php
$url = $_ENV['BUILD_URL'];
$res= json_decode(file_get_contents($url . 'api/json'));
$silent = false;
$message = '';
$action = 'reject'; // default no
switch ($res->result) {
case 'SUCCESS':
$message = 'Build ok!';
$silent = true;
$action = 'none';
break;
default:
$message = 'Build failed!';
break;
}
$diff_id = $_ENV['DIFF_ID'];
// convert the diff_id into the Differential revision id
$arcarg = escapeshellarg(json_encode(array("diff_id"=>$diff_id)));
$json = `echo $arcarg | arc call-conduit differential.getdiff`;
$rev_id = json_decode($json)->response->revisionID;
$arcarg = escapeshellarg(json_encode(array("revision_id" => $rev_id, "message" => $message, "action" => $action, "silent" => $silent)));
// post the comment
`echo $arcarg | arc call-conduit differential.createcomment`;
echo "## Figuring out rev number"
REVNO=$(echo {\"diff_id\":$DIFF_ID} | arc call-conduit differential.getdiff | php -r '$d=json_decode(file_get_contents("php://stdin")); $r = $d->response->sourceControlBaseRevision; echo substr($r, strrpos($r, "@")+1);')
echo "## Updating to it"
svn up -r$REVNO
echo "## Patching"
arc patch --no-ansi --diff $DIFF_ID
# your code to run the build/tests here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment