Advanced build queries



I’d like to ask if there is a way to execute queries about builds. I have two specific queries in mind:

  1. what versions of the input resources were used in build X - this information is visible in the GUI (build page) but I can’t find a way to query it with fly
  2. has there been a successful execution of job Y with version Z of resource FOO - similarly possible to get this information with GUI (resource screen, after expanding a version)

Is it possible to answer such questions from the command line?



There is no way to get this information from fly but you can with the (undocumented) API.

  1. The endpoint you’re looking for is /api/v1/builds/:build_id/resources.

    You can get the build_id of the job through fly builds or equivalently /api/v1/builds

    Once you’re logged in to the GUI you can see the api output by going to $CONCOURSE_URL/api/path. In order to get it working on the command line you will need an ATC bearer token. Once you’ve logged in to your target with fly you can look in ~/.flyrc for your token. Then you can run curl -H "Authorization: Bearer <your-token>" https://$CONCOURSE_URL/api/v1/builds/:build_id/resources

    Protip: you can extract the bearer token from your ~/.flyrc programmatically with bosh int --path /targets/<target>/token/value ~/.flyrc

  2. /api/v1/teams/:team_name/pipelines/:pipeline_name/resources/:resource_name/versions/:resource_version_id/input_to is close to what you want.



Thanks Colin! Feels like it could be a bit easier but I should be able to do what I need.