-
Notifications
You must be signed in to change notification settings - Fork 0
Add gitlab-list-runners.sh to enumerate GitLab runners #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||
|
|
||||||||||||||||
| set -euo pipefail | ||||||||||||||||
|
|
||||||||||||||||
| usage() { | ||||||||||||||||
| cat <<'EOF' | ||||||||||||||||
| Usage: gitlab-list-runners.sh [--table] | ||||||||||||||||
|
|
||||||||||||||||
| Enumerate all runners attached to a GitLab instance (admin API). | ||||||||||||||||
|
|
||||||||||||||||
| Requirements: | ||||||||||||||||
| - glab CLI authenticated to the target GitLab instance | ||||||||||||||||
| - jq for table output | ||||||||||||||||
|
|
||||||||||||||||
| Options: | ||||||||||||||||
| --table Print a human-readable table instead of raw JSON | ||||||||||||||||
| -h, --help Show this help message | ||||||||||||||||
|
|
||||||||||||||||
| Examples: | ||||||||||||||||
| gitlab-list-runners.sh | ||||||||||||||||
| gitlab-list-runners.sh --table | ||||||||||||||||
| EOF | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if ! command -v glab >/dev/null 2>&1; then | ||||||||||||||||
| echo "Error: glab is required. Install it and run 'glab auth login'." >&2 | ||||||||||||||||
| exit 1 | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| OUTPUT_TABLE=false | ||||||||||||||||
|
|
||||||||||||||||
| while [ "$#" -gt 0 ]; do | ||||||||||||||||
| case "$1" in | ||||||||||||||||
| --table) | ||||||||||||||||
| OUTPUT_TABLE=true | ||||||||||||||||
| ;; | ||||||||||||||||
| -h|--help) | ||||||||||||||||
| usage | ||||||||||||||||
| exit 0 | ||||||||||||||||
| ;; | ||||||||||||||||
| *) | ||||||||||||||||
| echo "Unknown argument: $1" >&2 | ||||||||||||||||
| usage >&2 | ||||||||||||||||
| exit 1 | ||||||||||||||||
| ;; | ||||||||||||||||
| esac | ||||||||||||||||
| shift | ||||||||||||||||
| done | ||||||||||||||||
|
|
||||||||||||||||
| RUNNERS_JSON=$(glab api --paginate "runners/all") | ||||||||||||||||
|
||||||||||||||||
| RUNNERS_JSON=$(glab api --paginate "runners/all") | |
| if ! RUNNERS_JSON=$(glab api --paginate "runners/all"); then | |
| echo "Error: failed to list GitLab runners via glab API." >&2 | |
| echo "Make sure glab is authenticated to the target instance (run 'glab auth login')" >&2 | |
| echo "and that your user has administrator permissions to access the runners API." >&2 | |
| exit 1 | |
| fi |
Copilot
AI
Feb 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'column' command may not be available on all systems by default. Consider adding a check for 'column' availability when '--table' is requested, similar to how 'jq' is checked. This will provide a clearer error message if the command is missing.
Copilot
AI
Feb 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the GitLab API returns an empty array for runners, the jq command '.[]' will produce no output, resulting in only the header line being displayed in table mode. While this is technically correct behavior, consider adding a check to inform the user when no runners are found to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Requirements section lists 'jq for table output' but does not mention that the 'column' command is also required for table formatting. This should be added to the requirements to accurately inform users of all dependencies.