Means to query application metadata

I was wondering if it’s possible to query the Aptible API to determine the value for the last successfully deployed APTIBLE_GIT_REF?

Yes; this is exposed in our API, and although we don’t currently make any API stability guarantees, this particular bit is indeed unlikely to change.

Are you using one of our Ruby API libraries, or accessing the API directly using a hand-rolled client? I’ll let you know what the best way to access that information is accordingly.

Cheers,

Hey, Thomas,

I was thinking of using curl or wget as I’m trying to use the results in a bash script.

Thanks,
Rob

This is something we’re planning to add to the CLI - would something like this work for you?

aptible inspect $(aptible inspect 'https://api.aptible.com/apps/42' | jq -r ._links.current_image.href) | jq -r .git_ref

For this to work, you’d need to:

  • Log in to Aptible ahead of time using aptible login
  • Have the Aptible CLI and jq installed (the latter is used here to parse JSON)

Thanks, Thomas. The twist here is that I’m trying to run this as part of my deployment – specifically to notify New Relic only on a new deployment rather than any time there’s a deployment. So I’m guessing that running the Aptible toolbelt isn’t an option or might be problematic from the perspective of authentication?

Hey @rob,

  • Regarding the toolbelt: this is usually reasonably easy to install on the fly. Are we talking about running this in e.g. CI script here?
  • Regarding authentication: if you’re trying to retrieve this information from Aptible, then yes you will need to log in. You can set up a machine user to do so (it’s possible to give them minimal permissions and log in non-interactively), but there’s no getting around the fact that the Aptible API will not provide metadata about your app without you logging in first.
1 Like

@rob: FYI, if you’d like to use aptible inspect, this is live in the latest CLI (v0.9.0).

1 Like