-
-
Save KyMidd/cb0cd424d8292effe0ffc6831285b053 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find all project keys | |
STASH_PROJECT_KEYS=$(curl -s --user $STASH_USER:$STASH_PASS https://$STASH_URL/rest/api/1.0/projects\?limit\=1000 $| jq -r ".values[].key") | |
# Iterate over list of repos, generate repo clone urls | |
### Loop over every repo in environment | |
while IFS=$'\n' read -r PROJECT_KEY; do | |
# Set counter var | |
OPEN_PR_COUNT=0 | |
echo "X Searching project: $PROJECT_KEY" | |
# Find all repos in project | |
ALL_REPOS_IN_PROJECT=$(curl -s --user $STASH_USER:$STASH_PASS https://$STASH_URL/rest/api/1.0/projects/$PROJECT_KEY/repos\?limit\=1000 $| jq -r '.values[].slug') | |
while IFS=$'\n' read -r REPO_NAME; do | |
#echo "- Searching repo: $REPO_NAME" | |
# Find count of open PRs in repo | |
REPO_OPEN_PR_COUNT=$(curl -s --user $STASH_USER:$STASH_PASS https://$STASH_URL/rest/api/1.0/projects/$PROJECT_KEY/repos/$REPO_NAME/pull-requests $| jq -r .size) | |
echo "- Repo $REPO_NAME has $REPO_OPEN_PR_COUNT open PRs" | |
# Increment counter var | |
((OPEN_PR_COUNT=OPEN_PR_COUNT+REPO_OPEN_PR_COUNT)) | |
done <<< "$ALL_REPOS_IN_PROJECT" | |
echo "$PROJECT_KEY has $OPEN_PR_COUNT open PRs" | |
echo "$PROJECT_KEY,$OPEN_PR_COUNT" >> project_open_prs.csv | |
done <<< "$STASH_PROJECT_KEYS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment