mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Move build variables into HarbormasterBuildableInterface
Summary: Ref T1049. This moves the declaration of build variables onto HarbormasterBuildableInterface, allowing new classes implementing HarbormasterBuildableInterface to declare their own variables. Test Plan: Implemented it on another class, saw the build variables appear. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T1049 Differential Revision: https://secure.phabricator.com/D9618
This commit is contained in:
parent
5013969a54
commit
f7f8664456
6 changed files with 92 additions and 27 deletions
|
@ -333,6 +333,38 @@ final class DifferentialDiff
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getBuildVariables() {
|
||||
$results = array();
|
||||
|
||||
$results['buildable.diff'] = $this->getID();
|
||||
$revision = $this->getRevision();
|
||||
$results['buildable.revision'] = $revision->getID();
|
||||
$repo = $revision->getRepository();
|
||||
|
||||
if ($repo) {
|
||||
$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 )------------------------- */
|
||||
|
||||
|
|
|
@ -361,6 +361,14 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
return $this->getPHID();
|
||||
}
|
||||
|
||||
public function getBuildVariables() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getAvailableBuildVariables() {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||
|
||||
|
|
|
@ -5,4 +5,8 @@ interface HarbormasterBuildableInterface {
|
|||
public function getHarbormasterBuildablePHID();
|
||||
public function getHarbormasterContainerPHID();
|
||||
|
||||
public function getBuildVariables();
|
||||
|
||||
public function getAvailableBuildVariables();
|
||||
|
||||
}
|
||||
|
|
|
@ -250,5 +250,13 @@ final class HarbormasterBuildable extends HarbormasterDAO
|
|||
return $this->getContainerPHID();
|
||||
}
|
||||
|
||||
public function getBuildVariables() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getAvailableBuildVariables() {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -235,22 +235,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
|||
$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();
|
||||
}
|
||||
$object_variables = $object->getBuildVariables();
|
||||
|
||||
if ($repo) {
|
||||
$results['repository.callsign'] = $repo->getCallsign();
|
||||
$results['repository.vcs'] = $repo->getVersionControlSystem();
|
||||
$results['repository.uri'] = $repo->getPublicCloneURI();
|
||||
}
|
||||
$results = $object_variables + $results;
|
||||
|
||||
$results['step.timestamp'] = time();
|
||||
$results['build.id'] = $this->getID();
|
||||
|
@ -259,22 +246,23 @@ final class HarbormasterBuild extends HarbormasterDAO
|
|||
}
|
||||
|
||||
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.'),
|
||||
$objects = id(new PhutilSymbolLoader())
|
||||
->setAncestorClass('HarbormasterBuildableInterface')
|
||||
->loadObjects();
|
||||
|
||||
$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 ($objects as $object) {
|
||||
$variables[] = $object->getAvailableBuildVariables();
|
||||
}
|
||||
|
||||
$variables = array_mergev($variables);
|
||||
return $variables;
|
||||
}
|
||||
|
||||
public function isComplete() {
|
||||
|
|
|
@ -282,6 +282,31 @@ final class PhabricatorRepositoryCommit
|
|||
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 )------------------------------------ */
|
||||
|
||||
|
|
Loading…
Reference in a new issue