Piping a view into a script

You have a pinned view that answers a question exactly right: everything targeting main, not draft, with a passing pipeline. You want the same rows in a shell script, for a standup summary, a release checklist, or a message posted to chat.

scripting
The view is defined once in the dashboard, where you can see whether it is right, and the script asks for it by name. The export returns the same rows the table renders, as a JSON array, and fails loudly on a name that does not exist.

Steps

StepWhat you do
1Build the view once in the terminal: b browse, f filter, P pin
2Name it something a script can refer to, for example release
3Run it from the command line
labdash export release --json | jq -r '.[] | "\(.project)!\(.iid)  \(.title)"'
platform/ingest!2841  Add retry budget to the ingest job
platform/cache!1190   Bump go-redis to v9.7
identity/auth!733     Migrate auth to OIDC

Where the view is defined

The view is defined in the place where you could see whether it was right, and the script asks for it by name. Re-expressing the same filter as command-line flags gives you a second thing to keep correct.

For general-purpose GitLab commands there is glab, which is official and good at exactly that. labdash export returns the rows of a view, and that is its whole surface.

Output

  • A JSON array of row objects, holding the same fields the table renders plus the web URL.
  • A non-zero exit code when the view name does not exist, so a typo fails the script instead of producing an empty list.
  • The same credential and instance settings the dashboard uses, including proxies and custom certificate authorities.
  • A read. Nothing is written anywhere.