Skip to content

Instantly share code, notes, and snippets.

@jprinet
Created August 22, 2023 09:59
Show Gist options
  • Save jprinet/37a701f47e61ea37c3e721dfe763836c to your computer and use it in GitHub Desktop.
Save jprinet/37a701f47e61ea37c3e721dfe763836c to your computer and use it in GitHub Desktop.
Get Git repositories from GE projects
#!/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
@jprinet
Copy link
Author

jprinet commented Aug 22, 2023

Call with
./process-scans.sh https://ge.solutions-team.gradle.com/ <MY-TOKEN> 1692603891

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment