Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15413455
D17282.id41575.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D17282.id41575.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1211,6 +1211,7 @@
'HarbormasterBuildableTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildableTransactionQuery.php',
'HarbormasterBuildableViewController' => 'applications/harbormaster/controller/HarbormasterBuildableViewController.php',
'HarbormasterBuildkiteBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php',
+ 'HarbormasterBuildkiteBuildableInterface' => 'applications/harbormaster/interface/HarbormasterBuildkiteBuildableInterface.php',
'HarbormasterBuildkiteHookController' => 'applications/harbormaster/controller/HarbormasterBuildkiteHookController.php',
'HarbormasterBuiltinBuildStepGroup' => 'applications/harbormaster/stepgroup/HarbormasterBuiltinBuildStepGroup.php',
'HarbormasterCircleCIBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterCircleCIBuildStepImplementation.php',
@@ -5091,6 +5092,7 @@
'PhabricatorExtendedPolicyInterface',
'HarbormasterBuildableInterface',
'HarbormasterCircleCIBuildableInterface',
+ 'HarbormasterBuildkiteBuildableInterface',
'PhabricatorApplicationTransactionInterface',
'PhabricatorDestructibleInterface',
),
@@ -8789,6 +8791,7 @@
'PhabricatorMentionableInterface',
'HarbormasterBuildableInterface',
'HarbormasterCircleCIBuildableInterface',
+ 'HarbormasterBuildkiteBuildableInterface',
'PhabricatorCustomFieldInterface',
'PhabricatorApplicationTransactionInterface',
'PhabricatorFulltextInterface',
diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php
--- a/src/applications/differential/storage/DifferentialDiff.php
+++ b/src/applications/differential/storage/DifferentialDiff.php
@@ -7,6 +7,7 @@
PhabricatorExtendedPolicyInterface,
HarbormasterBuildableInterface,
HarbormasterCircleCIBuildableInterface,
+ HarbormasterBuildkiteBuildableInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorDestructibleInterface {
@@ -621,6 +622,27 @@
return $ref;
}
+
+/* -( HarbormasterBuildkiteBuildableInterface )---------------------------- */
+
+ public function getBuildkiteBranch() {
+ $ref = $this->getStagingRef();
+
+ // NOTE: Circa late January 2017, Buildkite fails with the error message
+ // "Tags have been disabled for this project" if we pass the "refs/tags/"
+ // prefix via the API and the project doesn't have GitHub tag builds
+ // enabled, even if GitHub builds are disabled. The tag builds fine
+ // without this prefix.
+ $ref = preg_replace('(^refs/tags/)', '', $ref);
+
+ return $ref;
+ }
+
+ public function getBuildkiteCommit() {
+ return 'HEAD';
+ }
+
+
public function getStagingRef() {
// TODO: We're just hoping to get lucky. Instead, `arc` should store
// where it sent changes and we should only provide staging details
diff --git a/src/applications/harbormaster/interface/HarbormasterBuildkiteBuildableInterface.php b/src/applications/harbormaster/interface/HarbormasterBuildkiteBuildableInterface.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/interface/HarbormasterBuildkiteBuildableInterface.php
@@ -0,0 +1,11 @@
+<?php
+
+/**
+ * Support for Buildkite.
+ */
+interface HarbormasterBuildkiteBuildableInterface {
+
+ public function getBuildkiteBranch();
+ public function getBuildkiteCommit();
+
+}
diff --git a/src/applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php
--- a/src/applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php
+++ b/src/applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php
@@ -75,7 +75,7 @@
$buildable = $build->getBuildable();
$object = $buildable->getBuildableObject();
- if (!($object instanceof HarbormasterCircleCIBuildableInterface)) {
+ if (!($object instanceof HarbormasterBuildkiteBuildableInterface)) {
throw new Exception(
pht('This object does not support builds with Buildkite.'));
}
@@ -89,8 +89,8 @@
$pipeline);
$data_structure = array(
- 'commit' => $object->getCircleCIBuildIdentifier(),
- 'branch' => 'master',
+ 'commit' => $object->getBuildkiteCommit(),
+ 'branch' => $object->getBuildkiteBranch(),
'message' => pht(
'Harbormaster Build %s ("%s") for %s',
$build->getID(),
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
@@ -11,6 +11,7 @@
PhabricatorMentionableInterface,
HarbormasterBuildableInterface,
HarbormasterCircleCIBuildableInterface,
+ HarbormasterBuildkiteBuildableInterface,
PhabricatorCustomFieldInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorFulltextInterface,
@@ -590,6 +591,44 @@
}
+/* -( HarbormasterBuildkiteBuildableInterface )---------------------------- */
+
+
+ public function getBuildkiteBranch() {
+ $viewer = PhabricatorUser::getOmnipotentUser();
+ $repository = $this->getRepository();
+
+ $branches = DiffusionQuery::callConduitWithDiffusionRequest(
+ $viewer,
+ DiffusionRequest::newFromDictionary(
+ array(
+ 'repository' => $repository,
+ 'user' => $viewer,
+ )),
+ 'diffusion.branchquery',
+ array(
+ 'contains' => $this->getCommitIdentifier(),
+ 'repository' => $repository->getPHID(),
+ ));
+
+ if (!$branches) {
+ throw new Exception(
+ pht(
+ 'Commit "%s" is not an ancestor of any branch head, so it can not '.
+ 'be built with Buildkite.',
+ $this->getCommitIdentifier()));
+ }
+
+ $branch = head($branches);
+
+ return 'refs/heads/'.$branch['shortName'];
+ }
+
+ public function getBuildkiteCommit() {
+ return $this->getCommitIdentifier();
+ }
+
+
/* -( PhabricatorCustomFieldInterface )------------------------------------ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 6:51 PM (1 d, 54 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7434428
Default Alt Text
D17282.id41575.diff (6 KB)
Attached To
Mode
D17282: Navigage Buildkite builds with more nuance
Attached
Detach File
Event Timeline
Log In to Comment