Skip to content

Instantly share code, notes, and snippets.

@thomashartm
Created May 7, 2018 08:45
Show Gist options
  • Save thomashartm/5328235832219f404a9eb748ecf3bc56 to your computer and use it in GitHub Desktop.
Save thomashartm/5328235832219f404a9eb748ecf3bc56 to your computer and use it in GitHub Desktop.
Reads the jenkins plugins installed on an existing instance and exports the shortnames
#!/bin/bash
####################################
# Reads the jenkins plugins installed on an existing instance and exports the shortnames
# run as follows:
# export-jenkins-plugins.sh <server-adress> <username>
# e.g.
# export-jenkins-plugins.sh localhost:8080 admin
# This command requires to install jq
# https://stedolan.github.io/jq/download/
####################################
if [ $# -lt 1 ]; then
echo -e "At least a host parameter is expected. Please execute as follows:"
echo -e "export-jenkins-plugins.sh <host> <username>"
exit 1
fi
server_addr=${1}
if [ $# -lt 2 ]; then
user=""
else
user="-u ${2}"
fi
# condensed json
#format='{shortName, version,longName,url}'
#list of shortnames
format=".shortName"
curl -s -k $user "https://${server_addr}/pluginManager/api/json?depth=1" \
| jq ".plugins[]|${format}" -c | sort \
> plugin-list
echo "Hey my friend, here's your list: "
cat plugin-list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment