What variables are available for build step URIs?


#1

You can reference variables such as ${buildable.revision} in a build step URI. Is there a list of all of these? I am specifically interested in the repository name for the commit.

Cheers,
-kyle


Missing "Accepted Differential revision" condition in "Commit Content" Herald rule
#2

Scroll down in the Build Step page. The list is below the fold.


#3

sigh that’s embarrassing. Thanks for setting me straight.

Too bad it doesn’t have the name. I guess I’ll have to settle on the ALLCAPSCALLSIGN for ‘names’.


#4

It should have the repo phid, which will let you get all the data via another conduit call?


#5

Yes, I’m sure I can get there. But, that doesn’t fit nicely into a field in Jenkins where I can reference environment/from-url variables.


#6

If you want the {repository.name} it might be as simple as just adding it into the build variables in

repository/storage/PhabricatorRepositoryCommit.php

I’ve not done this for repository commits, but I have done the same for maniphest.tasks.

In a HTTP request, I’ve often found there aren’t enough/correct build variables. I know we can pass on the PHID, but in the past I didn’t want to pass over the PHID just for the destination service have to call back to phabricator to get basic information.

Try this pseudo code…

  public function getBuildVariables() {
    $results = array();

    $results['buildable.commit'] = $this->getCommitIdentifier();
    $repo = $this->getRepository();

    $results['repository.callsign'] = $repo->getCallsign();
    $results['repository.phid'] = $repo->getPHID();
    $results['repository.vcs'] = $repo->getVersionControlSystem();
    $results['repository.uri'] = $repo->getPublicCloneURI();

+   $results['repository.name'] = $repo->getName();

    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.phid' =>
        pht('The PHID 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.'),
+     'repository.name' =>
+        pht('The name of the repository in Phabricator.'),
    );
  }