fix: use Woodpecker v3 numeric repo IDs in API calls
Woodpecker v3 requires numeric repo IDs in API endpoints, not
owner/repo path segments. The old paths hit the SPA frontend
catch-all and return HTML, which downstream tools misinterpret
as auth failure (401).
- Add tools/woodpecker/_lib.sh with wp_resolve_repo_id() helper
that calls /api/repos/lookup/{owner}/{repo} to get numeric ID
- Update all 3 pipeline scripts to resolve repo ID before API calls
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ set -euo pipefail
|
||||
|
||||
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"
|
||||
source "$MOSAIC_HOME/tools/_lib/credentials.sh"
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
|
||||
|
||||
REPO=""
|
||||
LIMIT=20
|
||||
@@ -41,18 +42,15 @@ fi
|
||||
|
||||
# Auto-detect repo from git remote if not specified
|
||||
if [[ -z "$REPO" ]]; then
|
||||
remote_url=$(git remote get-url origin 2>/dev/null || true)
|
||||
if [[ -n "$remote_url" ]]; then
|
||||
REPO=$(echo "$remote_url" | sed -E 's|.*[:/]([^/]+/[^/]+?)(\.git)?$|\1|')
|
||||
else
|
||||
echo "Error: -r owner/repo required (not in a git repository)" >&2
|
||||
exit 1
|
||||
fi
|
||||
REPO=$(wp_detect_repo) || exit 1
|
||||
fi
|
||||
|
||||
# Resolve owner/repo to numeric ID (Woodpecker v3 API)
|
||||
REPO_ID=$(wp_resolve_repo_id "$REPO") || exit 1
|
||||
|
||||
response=$(curl -sk -w "\n%{http_code}" \
|
||||
-H "Authorization: Bearer $WOODPECKER_TOKEN" \
|
||||
"${WOODPECKER_URL}/api/repos/${REPO}/pipelines?per_page=${LIMIT}")
|
||||
"${WOODPECKER_URL}/api/repos/${REPO_ID}/pipelines?per_page=${LIMIT}")
|
||||
|
||||
http_code=$(echo "$response" | tail -n1)
|
||||
body=$(echo "$response" | sed '$d')
|
||||
|
||||
Reference in New Issue
Block a user