Created
August 22, 2023 09:59
-
-
Save jprinet/37a701f47e61ea37c3e721dfe763836c to your computer and use it in GitHub Desktop.
Get Git repositories from GE projects
This file contains hidden or 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
#!/bin/bash | |
geUrl=$1 | |
bearerToken=$2 | |
since=$3 | |
rm -f $0.out.txt | |
# We are fetching the first 1000 Gradle builds since $3 | |
gradleBuildScanIds=$(curl "${geUrl}/api/builds?fromInstant=${since}&maxBuilds=1000" --header "authorization: Bearer ${bearerToken}" | jq -r ".[] | select( .buildToolType == \"gradle\") | .id") | |
for buildScanId in $gradleBuildScanIds; do | |
echo "Processing $buildScanId" | |
buildData=$(curl "${geUrl}/api/builds/${buildScanId}/gradle-attributes" --header "authorization: Bearer ${bearerToken}" | jq -r '.values[] | select(.name | contains("Git repository")) | .value') | |
echo $buildData >> $0.out.txt | |
done | |
# We are fetching the first 1000 Maven builds since $3 | |
mavenBuildScanIds=$(curl "${geUrl}/api/builds?fromInstant=${since}&maxBuilds=1000" --header "authorization: Bearer ${bearerToken}" | jq -r ".[] | select( .buildToolType == \"maven\") | .id") | |
for buildScanId in $mavenBuildScanIds; do | |
echo "Processing $buildScanId" | |
buildData=$(curl "${geUrl}/api/builds/${buildScanId}/maven-attributes" --header "authorization: Bearer ${bearerToken}" | jq -r '.values[] | select(.name | contains("Git repository")) | .value') | |
echo $buildData >> $0.out.txt | |
done | |
# Display Git repositories | |
sort -rk1,1 $0.out.txt | sort -ruk1,1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Call with
./process-scans.sh https://ge.solutions-team.gradle.com/ <MY-TOKEN> 1692603891