#!/usr/bin/env bash

# Get project keys
PROJECT_KEYS=$(curl -s -X GET -H "Authorization: Bearer ${SONARQUBE_TOKEN}" "${SONARQUBE_URL}/api/projects/search" | jq -r '.components[].key')

# Iterate over project keys
for project_key in $PROJECT_KEYS; do
  echo "Project Key: $project_key"
  curl -s -X GET -H "Authorization: Bearer ${SONARQUBE_TOKEN}" "${SONARQUBE_URL}/api/qualitygates/project_status?projectKey=${project_key}" | jq .
  echo ""
done
