Last active
September 10, 2019 13:30
-
-
Save pmgupte/43f8f8b782b839fd648e13637317cd18 to your computer and use it in GitHub Desktop.
A script to get count of Jenkins plugins by license type. It downloads data about all plugins published to Jenkins Update Center, then downloads their pom.xml from SCM link mentioned in update-center.json, and finally counts occurrences per license name and prints stats. Referred this gist: https://gist.github.com/michaellihs/a844a93cb3575beb269…
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
#!/bin/bash | |
JQ=$(which jq) | |
CURL=$(which curl) | |
XPATH=$(which xpath) | |
$CURL -s https://updates.jenkins.io/current/update-center.actual.json -o update-center.actual.json | |
$JQ '.plugins[] | .scm' update-center.actual.json > plugin_repos.txt | |
input_file="plugin_repos.txt" | |
output_file="stats_jp.out.mid" | |
while IFS= read -r line | |
do | |
raw_content_url=$(echo $line | sed s/github.com/raw.githubusercontent.com/g | sed s/\"//g) | |
if [[ "$raw_content_url" == "null" ]]; then | |
continue | |
fi | |
license_name=$($CURL -s "$raw_content_url/master/pom.xml" | $XPATH -q -e '//project/licenses/license/name/text()') | |
echo "$license_name" >> stats_jp.out.mid | |
done < "$input_file" | |
sort stats_jp.out.mid | uniq -c | sort -bgr > stats_jp.out | |
cat stats_jp.out | |
rm update-center.actual.json plugin_repos.txt stats_jp.out.mid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment