diff --git a/scripts/monitor-deploy.sh b/scripts/monitor-deploy.sh index 4abda970..f11035e9 100755 --- a/scripts/monitor-deploy.sh +++ b/scripts/monitor-deploy.sh @@ -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 ""