Skip to content

Instantly share code, notes, and snippets.

@Kalisen
Created December 29, 2011 01:22
Show Gist options
  • Save Kalisen/1530977 to your computer and use it in GitHub Desktop.
Save Kalisen/1530977 to your computer and use it in GitHub Desktop.
list/upgrade plugin's version across all projects
#/bin/sh
PLUGIN_NAME=$1
PLUGIN_VERSION=$2
if [ -z "$1" -o "$1" = "-h" ]
then
echo Usage:
echo List usage of a plugin:
echo up_plugin PLUGIN_NAME
echo
echo Update plugin version:
echo up_plugin PLUGIN_NAME NEW_PLUGIN_VERSION
exit 1
fi
if [ -z "$2" ]
then
ACTION="LIST"
else
ACTION="UPGRADE"
fi
if [ "$ACTION" = "LIST" ]
then
echo "listing $PLUGIN_NAME plugin usages."
grep -RnH --include "BuildConfig.groovy" :$PLUGIN_NAME: *
else
CONFIG_FILES=$(grep -RnH --include "BuildConfig.groovy" :$PLUGIN_NAME: * | cut -d : -f 1)
echo "upgrading $PLUGIN_NAME plugin to version $PLUGIN_VERSION."
for file in $CONFIG_FILES
do
echo "processing file $file"
cp $file $file.old
cat $file.old | sed -E "s/:$PLUGIN_NAME:([0-9\.]*)(['\"])/:$PLUGIN_NAME:$PLUGIN_VERSION\2/g" > $file
rm $file.old
done
fi
@Kalisen
Copy link
Author

Kalisen commented Dec 29, 2011

running
up_plugin my-plugin 10.0
will update any BuildConfig.groovy file in any subdirectory of the current directory
and change the dependency version for 'my-plugin' to 10.0

@acreeger
Copy link

Nice!

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