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
scriptingA recording of a pinned view being exported. The dashboard is open on a tab named release holding eleven merge requests, and the tab is read once so the rows are visible. labdash is closed with q, and in the same terminal the command labdash export release --json is piped into jq, which prints one line per merge request: the project path, the internal id and the title. The command runs a second time with a view name that does not exist; it prints an error naming the view and the shell reports a non-zero exit code.
Steps
| Step | What you do |
|---|---|
| 1 | Build the view once in the terminal: b browse, f filter, P pin |
| 2 | Name it something a script can refer to, for example release |
| 3 | Run it from the command line |
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.
Related