@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added `build.id` variable and other improvements / fixes

Summary: This adds a `build.id` variable, cleans up the naming convention of other variables and also fixes an issue in the remote command to read the buffers after the command finishes.

Test Plan: Ran a build with `/bin/echo ${build.id}` and saw the build ID come through.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T1049

Differential Revision: https://secure.phabricator.com/D7540

authored by

James Rhodes and committed by
epriestley
3eaac9ed 197e9b6f

+33 -20
+8 -2
src/applications/harbormaster/step/RemoteCommandBuildStepImplementation.php
··· 31 31 $variables = $this->retrieveVariablesFromBuild($build); 32 32 $command = $settings['command']; 33 33 preg_match_all( 34 - "/\\\$\\{(?P<name>[a-z]+)\\}/", 34 + "/\\\$\\{(?P<name>[a-z\.]+)\\}/", 35 35 $command, 36 36 $matches); 37 37 foreach ($matches["name"] as $match) { 38 38 $parameters[] = idx($variables, $match, ""); 39 39 } 40 40 $command = str_replace("%", "%%", $command); 41 - $command = preg_replace("/\\\$\\{(?P<name>[a-z]+)\\}/", "%s", $command); 41 + $command = preg_replace("/\\\$\\{(?P<name>[a-z\.]+)\\}/", "%s", $command); 42 42 43 43 $command = vcsprintf( 44 44 $command, ··· 89 89 90 90 // Get the return value so we can log that as well. 91 91 list($err) = $future->resolve(); 92 + 93 + // Retrieve the last few bits of information. 94 + list($stdout, $stderr) = $future->read(); 95 + $log_stdout->append($stdout); 96 + $log_stderr->append($stderr); 97 + $future->discardBuffers(); 92 98 93 99 $log_stdout->finalize($start_stdout); 94 100 $log_stderr->finalize($start_stderr);
+25 -18
src/applications/harbormaster/step/VariableBuildStepImplementation.php
··· 4 4 5 5 public function retrieveVariablesFromBuild(HarbormasterBuild $build) { 6 6 $results = array( 7 - 'revision' => null, 8 - 'commit' => null, 9 - 'repository' => null, 10 - 'vcs' => null, 11 - 'uri' => null, 12 - 'timestamp' => null); 7 + 'buildable.revision' => null, 8 + 'buildable.commit' => null, 9 + 'repository.callsign' => null, 10 + 'repository.vcs' => null, 11 + 'repository.uri' => null, 12 + 'step.timestamp' => null, 13 + 'build.id' => null); 13 14 14 15 $buildable = $build->getBuildable(); 15 16 $object = $buildable->getBuildableObject(); 16 17 17 18 $repo = null; 18 19 if ($object instanceof DifferentialRevision) { 19 - $results['revision'] = $object->getID(); 20 + $results['buildable.revision'] = $object->getID(); 20 21 $repo = $object->getRepository(); 21 22 } else if ($object instanceof PhabricatorRepositoryCommit) { 22 - $results['commit'] = $object->getCommitIdentifier(); 23 + $results['buildable.commit'] = $object->getCommitIdentifier(); 23 24 $repo = $object->getRepository(); 24 25 } 25 26 26 - $results['repository'] = $repo->getCallsign(); 27 - $results['vcs'] = $repo->getVersionControlSystem(); 28 - $results['uri'] = $repo->getPublicRemoteURI(); 29 - $results['timestamp'] = time(); 27 + $results['repository.callsign'] = $repo->getCallsign(); 28 + $results['repository.vcs'] = $repo->getVersionControlSystem(); 29 + $results['repository.uri'] = $repo->getPublicRemoteURI(); 30 + $results['step.timestamp'] = time(); 31 + $results['build.id'] = $build->getID(); 30 32 31 33 return $results; 32 34 } ··· 44 46 45 47 public function getAvailableVariables() { 46 48 return array( 47 - 'revision' => pht('The differential revision ID, if applicable.'), 48 - 'commit' => pht('The commit identifier, if applicable.'), 49 - 'repository' => pht('The callsign of the repository in Phabricator.'), 50 - 'vcs' => pht('The version control system, either "svn", "hg" or "git".'), 51 - 'uri' => pht('The URI to clone or checkout the repository from.'), 52 - 'timestamp' => pht('The current UNIX timestamp.')); 49 + 'buildable.revision' => 50 + pht('The differential revision ID, if applicable.'), 51 + 'buildable.commit' => pht('The commit identifier, if applicable.'), 52 + 'repository.callsign' => 53 + pht('The callsign of the repository in Phabricator.'), 54 + 'repository.vcs' => 55 + pht('The version control system, either "svn", "hg" or "git".'), 56 + 'repository.uri' => 57 + pht('The URI to clone or checkout the repository from.'), 58 + 'step.timestamp' => pht('The current UNIX timestamp.'), 59 + 'build.id' => pht('The ID of the current build.')); 53 60 } 54 61 55 62 public function getSettingRemarkupInstructions() {