Page MenuHomePhabricator

D9618.id23061.diff
No OneTemporary

D9618.id23061.diff

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
@@ -333,6 +333,36 @@
return null;
}
+ public function getBuildVariables() {
+ $results = array();
+
+ $results['buildable.diff'] = $this->getID();
+ $revision = $this->getRevision();
+ $results['buildable.revision'] = $revision->getID();
+ $repo = $revision->getRepository();
+
+ $results['repository.callsign'] = $repo->getCallsign();
+ $results['repository.vcs'] = $repo->getVersionControlSystem();
+ $results['repository.uri'] = $repo->getPublicCloneURI();
+
+ return $results;
+ }
+
+ public function getAvailableBuildVariables() {
+ return array(
+ 'buildable.diff' =>
+ pht('The differential diff ID, if applicable.'),
+ 'buildable.revision' =>
+ pht('The differential revision ID, if applicable.'),
+ 'repository.callsign' =>
+ pht('The callsign of the repository in Phabricator.'),
+ 'repository.vcs' =>
+ pht('The version control system, either "svn", "hg" or "git".'),
+ 'repository.uri' =>
+ pht('The URI to clone or checkout the repository from.'),
+ );
+ }
+
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php
--- a/src/applications/differential/storage/DifferentialRevision.php
+++ b/src/applications/differential/storage/DifferentialRevision.php
@@ -361,6 +361,14 @@
return $this->getPHID();
}
+ public function getBuildVariables() {
+ return array();
+ }
+
+ public function getAvailableBuildVariables() {
+ return array();
+ }
+
/* -( PhabricatorSubscribableInterface )----------------------------------- */
diff --git a/src/applications/harbormaster/interface/HarbormasterBuildableInterface.php b/src/applications/harbormaster/interface/HarbormasterBuildableInterface.php
--- a/src/applications/harbormaster/interface/HarbormasterBuildableInterface.php
+++ b/src/applications/harbormaster/interface/HarbormasterBuildableInterface.php
@@ -5,4 +5,8 @@
public function getHarbormasterBuildablePHID();
public function getHarbormasterContainerPHID();
+ public function getBuildVariables();
+
+ public function getAvailableBuildVariables();
+
}
diff --git a/src/applications/harbormaster/storage/HarbormasterBuildable.php b/src/applications/harbormaster/storage/HarbormasterBuildable.php
--- a/src/applications/harbormaster/storage/HarbormasterBuildable.php
+++ b/src/applications/harbormaster/storage/HarbormasterBuildable.php
@@ -250,5 +250,13 @@
return $this->getContainerPHID();
}
+ public function getBuildVariables() {
+ return array();
+ }
+
+ public function getAvailableBuildVariables() {
+ return array();
+ }
+
}
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
@@ -235,21 +235,13 @@
$buildable = $this->getBuildable();
$object = $buildable->getBuildableObject();
- $repo = null;
- if ($object instanceof DifferentialDiff) {
- $results['buildable.diff'] = $object->getID();
- $revision = $object->getRevision();
- $results['buildable.revision'] = $revision->getID();
- $repo = $revision->getRepository();
- } else if ($object instanceof PhabricatorRepositoryCommit) {
- $results['buildable.commit'] = $object->getCommitIdentifier();
- $repo = $object->getRepository();
- }
+ // TODO Are we sure that at this point the object is
+ // guarenteed to be a HarbormasterBuildableInterface?
+ $object_variables = $object->getBuildVariables();
- if ($repo) {
- $results['repository.callsign'] = $repo->getCallsign();
- $results['repository.vcs'] = $repo->getVersionControlSystem();
- $results['repository.uri'] = $repo->getPublicCloneURI();
+ // TODO Fairly sure there is an easier way to do this in Phabricator...
+ foreach ($object_variables as $key => $value) {
+ $results[$key] = $value;
}
$results['step.timestamp'] = time();
@@ -259,22 +251,25 @@
}
public static function getAvailableBuildVariables() {
- return array(
- 'buildable.diff' =>
- pht('The differential diff ID, if applicable.'),
- 'buildable.revision' =>
- pht('The differential revision ID, if applicable.'),
- 'buildable.commit' => pht('The commit identifier, if applicable.'),
- 'repository.callsign' =>
- pht('The callsign of the repository in Phabricator.'),
- 'repository.vcs' =>
- pht('The version control system, either "svn", "hg" or "git".'),
- 'repository.uri' =>
- pht('The URI to clone or checkout the repository from.'),
+ $symbols = id(new PhutilSymbolLoader())
+ ->setAncestorClass('HarbormasterBuildableInterface')
+ ->selectAndLoadSymbols();
+
+ $variables = array();
+ $variables[] = array(
'step.timestamp' => pht('The current UNIX timestamp.'),
'build.id' => pht('The ID of the current build.'),
'target.phid' => pht('The PHID of the current build target.'),
);
+
+ foreach ($symbols as $symbol) {
+ $name = $symbol['name'];
+ $object = new $name();
+ $variables[] = $object->getAvailableBuildVariables();
+ }
+
+ $variables = array_mergev($variables);
+ return $variables;
}
public function isComplete() {
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
@@ -282,6 +282,31 @@
return $this->getRepository()->getPHID();
}
+ public function getBuildVariables() {
+ $results = array();
+
+ $results['buildable.commit'] = $this->getCommitIdentifier();
+ $repo = $this->getRepository();
+
+ $results['repository.callsign'] = $repo->getCallsign();
+ $results['repository.vcs'] = $repo->getVersionControlSystem();
+ $results['repository.uri'] = $repo->getPublicCloneURI();
+
+ return $results;
+ }
+
+ public function getAvailableBuildVariables() {
+ return array(
+ 'buildable.commit' => pht('The commit identifier, if applicable.'),
+ 'repository.callsign' =>
+ pht('The callsign of the repository in Phabricator.'),
+ 'repository.vcs' =>
+ pht('The version control system, either "svn", "hg" or "git".'),
+ 'repository.uri' =>
+ pht('The URI to clone or checkout the repository from.'),
+ );
+ }
+
/* -( PhabricatorCustomFieldInterface )------------------------------------ */

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 4, 9:06 AM (10 h, 57 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7221282
Default Alt Text
D9618.id23061.diff (6 KB)

Event Timeline