Improve pipeline detection and debugging

- Show local HEAD commit for comparison
- Add explicit sort order (id DESC) to get most recent pipeline
- Display pipeline created time and commit SHA
- Remove duplicate pipeline info output
This commit is contained in:
Graham McIntire 2026-01-15 09:04:19 -06:00
parent d4e3846e69
commit 37160fc33f
No known key found for this signature in database

View file

@ -121,7 +121,8 @@ get_current_branch() {
get_latest_pipeline() {
local branch=$1
local response=$(gitlab_api "/projects/${PROJECT_ID}/pipelines?ref=${branch}&per_page=1")
# Sort by id DESC to get the most recent pipeline (higher ID = newer)
local response=$(gitlab_api "/projects/${PROJECT_ID}/pipelines?ref=${branch}&per_page=1&order_by=id&sort=desc")
if [ $? -ne 0 ] || [ -z "$response" ]; then
return 1
@ -191,8 +192,12 @@ print_header() {
monitor_pipeline() {
local branch=$(get_current_branch)
local local_sha=$(git rev-parse HEAD 2>/dev/null | cut -c1-8)
echo -e "${BLUE}Branch:${NC} $branch"
if [ -n "$local_sha" ]; then
echo -e "${BLUE}Local HEAD:${NC} $local_sha"
fi
echo -e "${BLUE}Fetching latest pipeline...${NC}"
echo ""
@ -210,13 +215,9 @@ monitor_pipeline() {
local pipeline_sha=$(echo "$pipeline" | jq -r '.sha')
local pipeline_created=$(echo "$pipeline" | jq -r '.created_at')
echo -e "${BLUE}Pipeline ID:${NC} $pipeline_id"
echo -e "${BLUE}Pipeline:${NC} #$pipeline_id"
echo -e "${BLUE}Created:${NC} $pipeline_created"
echo -e "${BLUE}Commit:${NC} ${pipeline_sha:0:8}"
echo -e "${BLUE}Status:${NC} $pipeline_status"
echo ""
echo -e "${BLUE}Pipeline:${NC} #$pipeline_id"
echo -e "${BLUE}Status:${NC} $(status_icon $pipeline_status) $pipeline_status"
echo -e "${BLUE}URL:${NC} $pipeline_web_url"
echo ""