Loading...
Loading...
GitLab badge operations via API. ALWAYS use this skill when user wants to: (1) list project badges, (2) create pipeline/coverage badges, (3) update or delete badges, (4) preview badge rendering.
npx skill4agent add grandcamel/gitlab-assistant-skills gitlab-badgeglab api| Operation | Command Pattern | Risk |
|---|---|---|
| List badges | | - |
| Get badge | | - |
| Create badge | | ⚠️ |
| Update badge | | ⚠️ |
| Delete badge | | ⚠️ |
| Preview badge | | - |
| List group badges | | - |
api| Placeholder | Description |
|---|---|
| Full project path (e.g., |
| Numeric project ID |
| Project name |
| Project namespace |
| Default branch name |
| Current commit SHA |
# List all project badges
glab api projects/123/badges --method GET
# Using project path
glab api "projects/$(echo 'mygroup/myproject' | jq -Rr @uri)/badges"# List group badges (inherited by projects)
glab api groups/456/badges --method GET# Get specific badge
glab api projects/123/badges/1 --method GET# Create pipeline status badge
glab api projects/123/badges --method POST \
-f link_url="https://gitlab.com/%{project_path}/-/pipelines" \
-f image_url="https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg"
# Create coverage badge
glab api projects/123/badges --method POST \
-f link_url="https://gitlab.com/%{project_path}/-/jobs" \
-f image_url="https://gitlab.com/%{project_path}/badges/%{default_branch}/coverage.svg"
# Create custom badge (e.g., shields.io)
glab api projects/123/badges --method POST \
-f link_url="https://opensource.org/licenses/MIT" \
-f image_url="https://img.shields.io/badge/License-MIT-yellow.svg"
# Create named badge
glab api projects/123/badges --method POST \
-f name="Build Status" \
-f link_url="https://gitlab.com/%{project_path}/-/pipelines" \
-f image_url="https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg"
# Create release badge
glab api projects/123/badges --method POST \
-f link_url="https://gitlab.com/%{project_path}/-/releases" \
-f image_url="https://gitlab.com/%{project_path}/-/badges/release.svg"# Update badge URLs
glab api projects/123/badges/1 --method PUT \
-f link_url="https://new-link.com" \
-f image_url="https://new-image.com/badge.svg"
# Update badge name
glab api projects/123/badges/1 --method PUT \
-f name="New Badge Name"# Delete badge
glab api projects/123/badges/1 --method DELETE# Preview how a badge would render
glab api "projects/123/badges/render?link_url=https://gitlab.com/%{project_path}&image_url=https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg" --method GET# Link and image URLs
link_url="https://gitlab.com/%{project_path}/-/pipelines"
image_url="https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg"
glab api projects/123/badges --method POST \
-f link_url="$link_url" \
-f image_url="$image_url"[](https://gitlab.com/group/project/-/pipelines)link_url="https://gitlab.com/%{project_path}/-/jobs"
image_url="https://gitlab.com/%{project_path}/badges/%{default_branch}/coverage.svg"
glab api projects/123/badges --method POST \
-f link_url="$link_url" \
-f image_url="$image_url"link_url="https://gitlab.com/%{project_path}/-/releases"
image_url="https://gitlab.com/%{project_path}/-/badges/release.svg"
glab api projects/123/badges --method POST \
-f link_url="$link_url" \
-f image_url="$image_url"# License badge
glab api projects/123/badges --method POST \
-f name="License" \
-f link_url="https://opensource.org/licenses/MIT" \
-f image_url="https://img.shields.io/badge/License-MIT-blue.svg"
# Version badge
glab api projects/123/badges --method POST \
-f name="Version" \
-f link_url="https://gitlab.com/%{project_path}/-/releases" \
-f image_url="https://img.shields.io/badge/version-1.0.0-green.svg"
# Maintenance badge
glab api projects/123/badges --method POST \
-f name="Maintained" \
-f link_url="https://gitlab.com/%{project_path}" \
-f image_url="https://img.shields.io/badge/Maintained%3F-yes-green.svg"project_id=123
# Pipeline status
glab api projects/$project_id/badges --method POST \
-f name="Pipeline" \
-f link_url="https://gitlab.com/%{project_path}/-/pipelines" \
-f image_url="https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg"
# Coverage
glab api projects/$project_id/badges --method POST \
-f name="Coverage" \
-f link_url="https://gitlab.com/%{project_path}/-/jobs" \
-f image_url="https://gitlab.com/%{project_path}/badges/%{default_branch}/coverage.svg"
# Latest release
glab api projects/$project_id/badges --method POST \
-f name="Release" \
-f link_url="https://gitlab.com/%{project_path}/-/releases" \
-f image_url="https://gitlab.com/%{project_path}/-/badges/release.svg"# Get all badges and generate markdown
glab api projects/123/badges | \
jq -r '.[] | "[)](\(.rendered_link_url))"'source_project=123
target_project=456
# Get badges from source
badges=$(glab api projects/$source_project/badges)
# Create in target (using placeholders, so they'll work for the new project)
echo "$badges" | jq -c '.[]' | while read badge; do
link_url=$(echo "$badge" | jq -r '.link_url')
image_url=$(echo "$badge" | jq -r '.image_url')
name=$(echo "$badge" | jq -r '.name // empty')
glab api projects/$target_project/badges --method POST \
-f link_url="$link_url" \
-f image_url="$image_url" \
${name:+-f name="$name"}
done# List all badges with rendered URLs
glab api projects/123/badges | \
jq -r '.[] | "ID: \(.id)\n Name: \(.name // "unnamed")\n Image: \(.rendered_image_url)\n Link: \(.rendered_link_url)\n"'project_id=123
# Delete existing badges
glab api projects/$project_id/badges | jq -r '.[].id' | while read badge_id; do
glab api projects/$project_id/badges/$badge_id --method DELETE
done
# Create new badges
glab api projects/$project_id/badges --method POST \
-f name="Build" \
-f link_url="https://gitlab.com/%{project_path}/-/pipelines" \
-f image_url="https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg"| Issue | Cause | Solution |
|---|---|---|
| Badge not showing | URL incorrect | Check rendered URLs in API response |
| 403 Forbidden | Not maintainer | Need Maintainer+ role |
| Placeholder not replaced | Wrong syntax | Use |
| Coverage badge shows "unknown" | No coverage report | Configure CI to output coverage |
| Pipeline badge shows old status | Cache | Badge images may be cached |