Author: tchemit Date: 2014-01-17 18:18:41 +0100 (Fri, 17 Jan 2014) New Revision: 11 Url: http://forge.codelutin.com/projects/adminsys/repository/revisions/11 Log: mise en place de scripts pour maven-release Added: scripts/maven-release/deploy-nightly-builds-to-demo.sh scripts/maven-release/deploy-snapshot-site.sh scripts/maven-release/deploy-to-demo-from-GAV.sh scripts/maven-release/deploy-to-demo-from-SVN.sh scripts/maven-release/isis-fish-docs-site.sh scripts/maven-release/legacy/ scripts/maven-release/legacy/backup/ scripts/maven-release/legacy/backup/deploy-to-demo.sh scripts/maven-release/legacy/backup/deploy-to-demo2.sh scripts/maven-release/legacy/deploy-by-curl.sh scripts/maven-release/legacy/deploy-demo.sh scripts/maven-release/legacy/deploy-sandra-to-glon.sh scripts/maven-release/legacy/deploy-to-BETA.sh scripts/maven-release/legacy/deploy-to-demo-BETA.sh scripts/maven-release/legacy/deploy-to-demo-ng.sh scripts/maven-release/legacy/deploy-to-demo-ng2.sh scripts/maven-release/legacy/deploy-to-demo.sh scripts/maven-release/legacy/deploy-to-demo2-ng.sh scripts/maven-release/legacy/deploy-to-demo2.sh scripts/maven-release/legacy/deploy-to-glon-BETA.sh scripts/maven-release/legacy/deploy-to-latest.sh scripts/maven-release/legacy/mavenpom-update.sh scripts/maven-release/legacy/mmvn.sh scripts/maven-release/legacy/svn-update.sh scripts/maven-release/mvn-ep.sh Added: scripts/maven-release/deploy-nightly-builds-to-demo.sh =================================================================== --- scripts/maven-release/deploy-nightly-builds-to-demo.sh (rev 0) +++ scripts/maven-release/deploy-nightly-builds-to-demo.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,26 @@ +#! /bin/sh +MAILTO=dev@codelutin.com + +# construit et deploie les applications pour tous les projets marque dans /var/cache/redmine/nightly-build/x/y.deploy-demo +# ou x est le nom de la forge et y le nom du projet +# le projet doit alors se trouver dans /home/maven-release/projets/x/y +# Une fois l'application deployée, on supprimer le fichier de marquage + +cachedir=/var/cache/redmine/nightly-build +logdir=/var/log/deploy-nightly-builds-to-demo +for forge in $( ls $cachedir ) ; do + for f in $( ls $cachedir/$forge | grep .deploy-demo ) ; do + project=$(basename $f .deploy-demo) + logfile="$logdir/$forge-$project.log" + date >> $logfile + msgerror="Problème de construction ou déploiement du projet '$project' de la forge '$forge'.\nPlus de détails sur goh dans $logfile" + if [ -x /home/maven-release/projets/$forge/$project/deploy-latest-to-demo.sh ]; then + cd /home/maven-release/projets/$forge/$project/ + ./deploy-latest-to-demo.sh >> $logfile 2>&1 || echo -e $msgerror + else + echo "Script de déploiement (deploy-latest-to-demo.sh) manquant ou non exécutable" >> $logfile + fi + rm -rfv $cachedir/$forge/$f >> $logfile + done +done + Property changes on: scripts/maven-release/deploy-nightly-builds-to-demo.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/deploy-snapshot-site.sh =================================================================== --- scripts/maven-release/deploy-snapshot-site.sh (rev 0) +++ scripts/maven-release/deploy-snapshot-site.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,120 @@ +#! /bin/sh + +print_usage_and_exit() { + echo "-----------------------------------------------------------------------------------" + echo "usage $(basename $0) forge projectName [-h] [-d deployType] [-m extraBuildParameters]" + echo " forge (possible values : nuiton.org | chorem.org | forge.codelutin.com)" + echo " projectName (the directory name of the project in ~/projes/forge)" + echo " -h show usage and exit" + echo " -d deployType (deployType directory where to find svn)" + echo " -m extraBuildParameters (add extra parameters to maven build)" + echo "" + echo "example: $(basename $0) nuiton.org nuiton-utils" + echo "example: $(basename $0) chorem.org pollen -d latest -m\"-DperformRelease -Preporting\"" + echo "-----------------------------------------------------------------------------------" + + exit $1 +} + +# Deploy trunk site + +if [ $# -lt 2 ]; then + echo "Need at least 2 parameters" + print_usage_and_exit 1 +fi + +# Forge of the project +forge=$1 +shift + +# Project name +projectName=$1 +shift + +# deploy type +deployType="" + +# extra build params +extraBuildParams="" + +while getopts ":d:m:h" opt; do + case $opt in + h) + print_usage_and_exit 0 + ;; + d) + deployType="$OPTARG" + ;; + m) + extraBuildParams="$OPTARG" + ;; + \?) + echo "Option non reconnue: -$OPTARG" >&2 + print_usage_and_exit 1 + ;; + :) + echo "L'option -$OPTARG nécessite un argument." >&2 + print_usage_and_exit 1 + ;; + + esac +done + +# location of the project +dir=~/projets/$forge/$projectName/$deployType + +if [ ! -d $dir ]; then + + echo "Répertoire non trouvé $dir" + print_usage_and_exit 1 +fi + +if [ -z "$deployType" -a -d "$dir"latest ]; then + # for deploy-to-demo projects (by default use latest deploy type if none is specifiy) + dir="$dir"latest +fi + +if [ -d $dir/svn ]; then + # for deploy-to-demo projects (add the svn directoy) + dir=$dir/svn +fi + +echo "deploy trunk site from '$dir' (extra build params: $extraBuildParams)" +cd $dir + +# alway revert +svn revert -R . + +# always up to HEAD +svn up -rHEAD + +# Get project url +projectUrl=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:url" pom.xml` + +if [ -z $projectUrl ]; then + echo "pas de project.url trouvé dans le pom $dir"pom.xml + exit 1 +fi + +projectUrl=$projectUrl/SNAPSHOT +echo "project url : $projectUrl" + +# Get site deployement url +deployUrl=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:distributionManagement/p:site/p:url" pom.xml` + +if [ -z $deployUrl ]; then + echo "pas de project/distributionManagement/site/url trouvé dans le pom $dir/pom.xml" + exit 1 +fi + +deployUrl=$deployUrl/SNAPSHOT +echo "deploy url : $deployUrl" + +# Update pom project url and deploy url +xmlstarlet ed -P -S -N "p=http://maven.apache.org/POM/4.0.0" -u "/p:project/p:url" -v "$projectUrl" -u "/p:project/p:distributionManagement/p:site/p:url" -v "$deployUrl" pom.xml > pom.xml2 && mv pom.xml2 pom.xml + +# launch site-deploy +/opt/maven/bin/mvn clean verify site-deploy -DperformRelease $extraBuildParams + +# revert pom +svn revert pom.xml Property changes on: scripts/maven-release/deploy-snapshot-site.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/deploy-to-demo-from-GAV.sh =================================================================== --- scripts/maven-release/deploy-to-demo-from-GAV.sh (rev 0) +++ scripts/maven-release/deploy-to-demo-from-GAV.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,230 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +OLD_PATH=$(pwd) +APPLICATION_NAME=$(basename $OLD_PATH) + +DEPLOY_TYPES=$(find * -maxdepth 0 -type d -printf " %p") + +export JAVA_HOME=/opt/jdk +export JDK_HOME=$JAVA_HOME +export M2_HOME=/opt/maven + +bye_bye() { + cd $OLD_PATH + exit $1 +} + +print_usage_and_exit() { + echo "-----------------------------------------------------------------------------------" + echo "usage $(basename $0) [-h] [-b] [-d] [-k] [-m extraBuildParameters] [-r svnRevision] deployType" + echo " -h show usage and exit" + echo " -b for batch mode (no question asked)" + echo " -d for dryRun mode (nothing is deployed)" + echo " -k to keep incoming project version (do not transform version using the svn revision)" + echo " -m extraBuildParameters (add extra parameters to maven build)" + echo " -r svnRevision (update svn to a specific revision, by default use HEAD)" + echo " deployType type of deploy to do (must be one amoung [$DEPLOY_TYPES])" + echo "" + echo "example: $(basename $0) -b -m\"-DperformRelease -Preporting\" -r101010 latest" + echo "-----------------------------------------------------------------------------------" + + bye_bye $1 +} + +test_ok_or_bye_bye() { + if [ $1 -eq 1 ]; then + echo "KO" + echo "$2 (see at $LOG_FILE)" + bye_bye 1 + else + echo "OK" + fi +} +echo -n "0/4 Check options and prepare svn..." + +MAVEN_BUILD="clean install -Pcollect-deploy-files" +SVN_REV="HEAD" +KEEP_VERSION=0 # 0 when transform version using svn revision, 1 keep incoming version +BATCH_MODE=0 # 0 when interactive, 1 when batch mode +DRY_RUN=0 # 0 when execute, 1 when dry run +while getopts ":m:r:hbdk" opt; do + case $opt in + h) + echo "OK" + print_usage_and_exit 0 + ;; + b) + BATCH_MODE=1 + ;; + d) + DRY_RUN=1 + ;; + k) + KEEP_VERSION=1 + ;; + m) + MAVEN_BUILD="$MAVEN_BUILD $OPTARG" + ;; + r) + SVN_REV="$OPTARG" + ;; + \?) + echo "KO" + echo "Invalid option: -$OPTARG" >&2 + print_usage_and_exit 1 + ;; + :) + echo "KO" + echo "Option -$OPTARG requires an argument." >&2 + print_usage_and_exit 1 + ;; + esac + shift $((OPTIND-1)) +done + +# must have a last mandatory parameter +if [ ! $# -eq 1 ]; then + echo "KO" + echo "Mandatory deploy type not given" + print_usage_and_exit 1 +fi +DEPLOY_TYPE="$1" + +# check deploy type exist +if [ ! -d $DEPLOY_TYPE ]; then + echo "KO" + echo "Could not find deploy type $DEPLOY_TYPES (available: $DEPLOY_TYPES)" + bye_bye 1 +fi + +# check deploy structure +cd $DEPLOY_TYPE +if [ ! -f deploy ]; then + echo "KO" + echo "Could not find $DEPLOY_TYPE/deploy file" + bye_bye 1 +fi +if [ ! -f config ]; then + echo "KO" + echo "Could not find $DEPLOY_TYPE/config file" + bye_bye 1 +fi +if [ ! -d svn ]; then + echo "Could not find $DEPLOY_TYPE/svn directory" + bye_bye 1 +fi + +cd svn + +# revert svn +svn revert -R . --non-interactive > /dev/null + +# update svn +svn up -r$SVN_REV --non-interactive > /dev/null + +# get subversion revision +REV=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` + +# get project version +VERSION=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` + +# get new version +if [ $KEEP_VERSION -eq 1 ]; then + NEW_VERSION=$VERSION +else + NEW_VERSION=`${M2_HOME}/bin/mvn -N helper:transform-project-version -Dhelper.newVersionPattern="#V-rev#R" -Dhelper.revision=$REV -DhelperPluginVersion=2.0 -Dhelper.versionKey=deployKey help:evaluate -Dexpression=deployKey | grep -v "\[" | grep "-rev" | grep -v "Download"` +fi + +echo "OK" +echo "----------------------------------------------------------" +echo "--- Deploy summary ---------------------------------------" +echo "----------------------------------------------------------" +echo "- application = $APPLICATION_NAME" +echo "- deployType = $DEPLOY_TYPE" +if [ $BATCH_MODE -eq 1 ]; then + echo "- batchMode = ON" +fi +if [ $DRY_RUN -eq 1 ]; then + echo "- dryRun = ON" +fi +if [ $KEEP_VERSION -eq 1 ]; then + echo "- keepVersion = ON" +fi +echo "- revision detected = $REV" +echo "- version detected = $VERSION" +echo "- new version = $NEW_VERSION" +echo "- build parameters = $MAVEN_BUILD" +echo "----------------------------------------------------------" + +if [ $BATCH_MODE -eq 0 ]; then + # ask user to confirm + echo -n "Accept the change ? [Y/n]" + read r + if [ ! -z "$r" -o "$r" = "Y" ]; then + echo "User cancel operation" + bye_bye 1 + fi +fi + +# log file +LOG_FILE=/tmp/deploy-to-demo-$APPLICATION_NAME-$DEPLOY_TYPE.log + +# change version in pom.xml +echo -n "1/4 Change to version $NEW_VERSION..." +if [ $KEEP_VERSION -eq 1 ]; then + echo "OK (keep version, skip this step)" +else + ${M2_HOME}/bin/mvn versions:set -DnewVersion=$NEW_VERSION > $LOG_FILE + test_ok_or_bye_bye $? "Error while executing '${M2_HOME}/bin/mvn versions:set -DnewVersion=$NEW_VERSION'" +fi + +# build application +echo -n "2/4 Build application..." +${M2_HOME}/bin/mvn $MAVEN_BUILD > $LOG_FILE +test_ok_or_bye_bye $? "Error while executing '${M2_HOME}/bin/mvn $MAVEN_BUILD'" + +cd .. + +echo -n "3/4 Deploy to demo..." + +if [ $DRY_RUN -eq 1 ]; then + echo "OK (dry run, skip this step)" +else + + # build the curl deploy options + DEPLOY_ARGS="-s " + for i in $(cat deploy); do + DEPLOY_ARGS="$DEPLOY_ARGS -F \"$i\""; + done + for i in $(cat svn/target/collect-deploy-files.txt); do + DEPLOY_ARGS="$DEPLOY_ARGS -F \"APP_WAR=@$i\"" + continue + done + + # Create a file to execute the curl command (pb with @ in bash execution...) + DEPLOY_ARGS="$DEPLOY_ARGS http://demo-ng.codelutin.com/deploy.cgi" + DEPLOY_COMMAND=/tmp/deploy-to-demo-curl-$APPLICATION_NAME.sh + cat << EOF > $DEPLOY_COMMAND + curl $DEPLOY_ARGS +EOF + + chmod +x $DEPLOY_COMMAND + + # execute the curl command + cat $DEPLOY_COMMAND > $LOG_FILE + . $DEPLOY_COMMAND >> $LOG_FILE + + # check there is a Deploy success in response" + if [ $? -eq 0 ]; then + grep "Deploy success" $LOG_FILE > /dev/null + fi + test_ok_or_bye_bye $? "Could not deploy to demo" +fi + +# revert any change +echo -n "4/4 Revert local modifications..." +svn revert -R svn > /dev/null +echo "OK" + +bye_bye 0 Property changes on: scripts/maven-release/deploy-to-demo-from-GAV.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/deploy-to-demo-from-SVN.sh =================================================================== --- scripts/maven-release/deploy-to-demo-from-SVN.sh (rev 0) +++ scripts/maven-release/deploy-to-demo-from-SVN.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,230 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +OLD_PATH=$(pwd) +APPLICATION_NAME=$(basename $OLD_PATH) + +DEPLOY_TYPES=$(find * -maxdepth 0 -type d -printf " %p") + +export JAVA_HOME=/opt/jdk +export JDK_HOME=$JAVA_HOME +export M2_HOME=/opt/maven + +bye_bye() { + cd $OLD_PATH + exit $1 +} + +print_usage_and_exit() { + echo "-----------------------------------------------------------------------------------" + echo "usage $(basename $0) [-h] [-b] [-d] [-k] [-m extraBuildParameters] [-r svnRevision] deployType" + echo " -h show usage and exit" + echo " -b for batch mode (no question asked)" + echo " -d for dryRun mode (nothing is deployed)" + echo " -k to keep incoming project version (do not transform version using the svn revision)" + echo " -m extraBuildParameters (add extra parameters to maven build)" + echo " -r svnRevision (update svn to a specific revision, by default use HEAD)" + echo " deployType type of deploy to do (must be one amoung [$DEPLOY_TYPES])" + echo "" + echo "example: $(basename $0) -b -m\"-DperformRelease -Preporting\" -r101010 latest" + echo "-----------------------------------------------------------------------------------" + + bye_bye $1 +} + +test_ok_or_bye_bye() { + if [ $1 -eq 1 ]; then + echo "KO" + echo "$2 (see at $LOG_FILE)" + bye_bye 1 + else + echo "OK" + fi +} +echo -n "0/4 Check options and prepare svn..." + +MAVEN_BUILD="clean install -Pcollect-deploy-files" +SVN_REV="HEAD" +KEEP_VERSION=0 # 0 when transform version using svn revision, 1 keep incoming version +BATCH_MODE=0 # 0 when interactive, 1 when batch mode +DRY_RUN=0 # 0 when execute, 1 when dry run +while getopts ":m:r:hbdk" opt; do + case $opt in + h) + echo "OK" + print_usage_and_exit 0 + ;; + b) + BATCH_MODE=1 + ;; + d) + DRY_RUN=1 + ;; + k) + KEEP_VERSION=1 + ;; + m) + MAVEN_BUILD="$MAVEN_BUILD $OPTARG" + ;; + r) + SVN_REV="$OPTARG" + ;; + \?) + echo "KO" + echo "Invalid option: -$OPTARG" >&2 + print_usage_and_exit 1 + ;; + :) + echo "KO" + echo "Option -$OPTARG requires an argument." >&2 + print_usage_and_exit 1 + ;; + esac + shift $((OPTIND-1)) +done + +# must have a last mandatory parameter +if [ ! $# -eq 1 ]; then + echo "KO" + echo "Mandatory deploy type not given" + print_usage_and_exit 1 +fi +DEPLOY_TYPE="$1" + +# check deploy type exist +if [ ! -d $DEPLOY_TYPE ]; then + echo "KO" + echo "Could not find deploy type $DEPLOY_TYPES (available: $DEPLOY_TYPES)" + bye_bye 1 +fi + +# check deploy structure +cd $DEPLOY_TYPE +if [ ! -f deploy ]; then + echo "KO" + echo "Could not find $DEPLOY_TYPE/deploy file" + bye_bye 1 +fi +if [ ! -f config ]; then + echo "KO" + echo "Could not find $DEPLOY_TYPE/config file" + bye_bye 1 +fi +if [ ! -d svn ]; then + echo "Could not find $DEPLOY_TYPE/svn directory" + bye_bye 1 +fi + +cd svn + +# revert svn +svn revert -R . --non-interactive > /dev/null + +# update svn +svn up -r$SVN_REV --non-interactive > /dev/null + +# get subversion revision +REV=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` + +# get project version +VERSION=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` + +# get new version +if [ $KEEP_VERSION -eq 1 ]; then + NEW_VERSION=$VERSION +else + NEW_VERSION=`${M2_HOME}/bin/mvn -N helper:transform-project-version -Dhelper.newVersionPattern="#V-rev#R" -Dhelper.revision=$REV -DhelperPluginVersion=2.0 -Dhelper.versionKey=deployKey help:evaluate -Dexpression=deployKey | grep -v "\[" | grep "-rev" | grep -v "Download"` +fi + +echo "OK" +echo "----------------------------------------------------------" +echo "--- Deploy summary ---------------------------------------" +echo "----------------------------------------------------------" +echo "- application = $APPLICATION_NAME" +echo "- deployType = $DEPLOY_TYPE" +if [ $BATCH_MODE -eq 1 ]; then + echo "- batchMode = ON" +fi +if [ $DRY_RUN -eq 1 ]; then + echo "- dryRun = ON" +fi +if [ $KEEP_VERSION -eq 1 ]; then + echo "- keepVersion = ON" +fi +echo "- revision detected = $REV" +echo "- version detected = $VERSION" +echo "- new version = $NEW_VERSION" +echo "- build parameters = $MAVEN_BUILD" +echo "----------------------------------------------------------" + +if [ $BATCH_MODE -eq 0 ]; then + # ask user to confirm + echo -n "Accept the change ? [Y/n]" + read r + if [ ! -z "$r" -o "$r" = "Y" ]; then + echo "User cancel operation" + bye_bye 1 + fi +fi + +# log file +LOG_FILE=/tmp/deploy-to-demo-$APPLICATION_NAME-$DEPLOY_TYPE.log + +# change version in pom.xml +echo -n "1/4 Change to version $NEW_VERSION..." +if [ $KEEP_VERSION -eq 1 ]; then + echo "OK (keep version, skip this step)" +else + ${M2_HOME}/bin/mvn versions:set -DnewVersion=$NEW_VERSION > $LOG_FILE + test_ok_or_bye_bye $? "Error while executing '${M2_HOME}/bin/mvn versions:set -DnewVersion=$NEW_VERSION'" +fi + +# build application +echo -n "2/4 Build application..." +${M2_HOME}/bin/mvn $MAVEN_BUILD > $LOG_FILE +test_ok_or_bye_bye $? "Error while executing '${M2_HOME}/bin/mvn $MAVEN_BUILD'" + +cd .. + +echo -n "3/4 Deploy to demo..." + +if [ $DRY_RUN -eq 1 ]; then + echo "OK (dry run, skip this step)" +else + + # build the curl deploy options + DEPLOY_ARGS="-s " + for i in $(cat deploy); do + DEPLOY_ARGS="$DEPLOY_ARGS -F \"$i\""; + done + for i in $(cat svn/target/collect-deploy-files.txt); do + DEPLOY_ARGS="$DEPLOY_ARGS -F \"APP_WAR=@$i\"" + continue + done + + # Create a file to execute the curl command (pb with @ in bash execution...) + DEPLOY_ARGS="$DEPLOY_ARGS http://demo-ng.codelutin.com/deploy.cgi" + DEPLOY_COMMAND=/tmp/deploy-to-demo-curl-$APPLICATION_NAME.sh + cat << EOF > $DEPLOY_COMMAND + curl $DEPLOY_ARGS +EOF + + chmod +x $DEPLOY_COMMAND + + # execute the curl command + cat $DEPLOY_COMMAND > $LOG_FILE + . $DEPLOY_COMMAND >> $LOG_FILE + + # check there is a Deploy success in response" + if [ $? -eq 0 ]; then + grep "Deploy success" $LOG_FILE > /dev/null + fi + test_ok_or_bye_bye $? "Could not deploy to demo" +fi + +# revert any change +echo -n "4/4 Revert local modifications..." +svn revert -R svn > /dev/null +echo "OK" + +bye_bye 0 Property changes on: scripts/maven-release/deploy-to-demo-from-SVN.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/isis-fish-docs-site.sh =================================================================== --- scripts/maven-release/isis-fish-docs-site.sh (rev 0) +++ scripts/maven-release/isis-fish-docs-site.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,17 @@ +#!/bin/sh + +# +# Regenere le site web de la documentation isis-fish +# si l'argument clean est passe, alors un clean est fait avant site +# FIXME tchemit-2011-12-25 : pas une bonne idée de déployer quelquechose qui n'a pas été cleané avant ... + +#export MVN=/opt/maven/bin/mvn +export MVN=/opt/repository/apache-maven-3.0.5/bin/mvn +export M2_HOME=/opt/repository/apache-maven-3.0.5 + +( +date +cd /home/maven-release/projets/forge.codelutin.com/isis-fish-docs/svn/ +svn up +$MVN $1 site-deploy +) >> /var/log/isis-fish-docs.log Property changes on: scripts/maven-release/isis-fish-docs-site.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/backup/deploy-to-demo.sh =================================================================== --- scripts/maven-release/legacy/backup/deploy-to-demo.sh (rev 0) +++ scripts/maven-release/legacy/backup/deploy-to-demo.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,14 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +if [ $# -lt 1 ]; then + echo "usage : $0 webmodule [extra build parameters]" + exit 0 +fi + +webmodule=$1 +shift 1 +artifact=$webmodule + +deploy-to-demo2.sh $webmodule $artifact $@ + \ No newline at end of file Property changes on: scripts/maven-release/legacy/backup/deploy-to-demo.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/backup/deploy-to-demo2.sh =================================================================== --- scripts/maven-release/legacy/backup/deploy-to-demo2.sh (rev 0) +++ scripts/maven-release/legacy/backup/deploy-to-demo2.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,114 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +# checking usage + +if [ $# -lt 1 ]; then + echo "usage : $0 webmodule artifact [extra build parameters]" + exit 0 +fi + +if [ ! -d $1 ]; then + echo "$1 must be an existing directory" + echo "usage : $0 webmodule artifact [extra build parameters]" + exit 0 +fi + +# reading and using first command-line arguments + +applicationName=$(basename `pwd`) # the D directory, on demo server, like /var/local/D/... +webModule=$1 # name of the maven module (directory name) that produces the war +artifact=$2 # name of the .war file to find in "target" directory of webModule + +shift +shift + +# remaining arguments are maven build arguments + +buildParameters="clean install $@" + + +# first do a up +svn up + +# get subversion revision +rev=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` + +# get project version +version=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` + +# get version suffix (Snapshot or not snapshot) +versionSuffix="" + +#echo $version | grep -e "-SNAPSHOT" > /dev/null +echo $version | grep -e "-" > /dev/null +if [ $? -eq 0 ]; then + versionSuffix=`echo $version | sed "s/[^-]*\(-.*\)/\1/"` + #versionSuffix="-SNAPSHOT" +fi + +# get new version to apply +newVersion=`echo $version | cut -d'-' -f1`"-rev-$rev$versionSuffix" +echo "application $applicationName, webmodule $webModule, artifact $artifact" +echo "revision detected : $rev - version detected : $version" +echo -n "new version = $newVersion, do the change ? [Y/n]" +read r + +if [ -z "$r" -o "$r" = "Y" ]; then + + logFile=/tmp/deploy-to-demo-$webModule.log + + # change version in pom.xml + echo -n "1/5 Change to version $newVersion..." + mvn versions:set -DnewVersion=$newVersion > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn versions:set -DnewVersion=$newVersion' (see at $logFile)" + else + echo "OK" + + # build application + echo -n "2/5 Build application mvn $buildParameters" + mvn $buildParameters > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn $buildParameters' (see at $logFile)" + else + echo "OK" + + # copy war to demo and (if ok) launch deploy.sh script from application location on demo (var/local/xxx) + warLocation="$webModule/target/$artifact-$newVersion.war" + warDestination=/var/local/$applicationName/war + echo -n "3/5 Deploy $warLocation to $warDestination..." + scp $warLocation root@demo.codelutin.com:$warDestination > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Could not deploy to demo (see at $logFile)" + else + echo "OK" + + # find and execute the deploy.sh file specific to the application + scriptToExecute="( cd /var/local/$applicationName ; ./deploy.sh $newVersion )" + echo -n "4/5 Execute on demo : $scriptToExecute..." + (cd $webModule ; mvn org.nuiton:helper-maven-plugin:1.4:execute-remote-command -N -Dhelper.repositoryId=demo.codelutin.com -Dhelper.repositoryUrl=scpexe://demo.codelutin.com -Dhelper.command="$scriptToExecute" > $logFile) + + if [ $? -eq 1 ]; then + echo "KO" + echo"Could not execute script $scriptToExecute on demo (see at $logFile)" + else + echo "OK" + fi + fi + fi + fi + + # revert any change + echo -n "5/5 Revert local modifications..." + svn st | xargs svn revert > /dev/null + echo "OK" + +fi + Property changes on: scripts/maven-release/legacy/backup/deploy-to-demo2.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-by-curl.sh =================================================================== --- scripts/maven-release/legacy/deploy-by-curl.sh (rev 0) +++ scripts/maven-release/legacy/deploy-by-curl.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,29 @@ +#!/bin/bash +# script to deploy a form using curl command + +# checking usage + +if [ $# -lt 3 ]; then + echo "usage : $0 applicationName formInputFile url" + exit 0 +fi + +applicationName=$1 +inputFile=$2 +url=$3 + +args="" +while read line +do + args="$args -F \"$line\""; +done < $inputFile + +args="$args $url" + +echo "" +echo "curl $args" +echo "" + +echo "curl $args" > /tmp/yo +chmod +x /tmp/yo +bash /tmp/yo Property changes on: scripts/maven-release/legacy/deploy-by-curl.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-demo.sh =================================================================== --- scripts/maven-release/legacy/deploy-demo.sh (rev 0) +++ scripts/maven-release/legacy/deploy-demo.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,230 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +OLD_PATH=$(pwd) +APPLICATION_NAME=$(basename $OLD_PATH) + +DEPLOY_TYPES=$(find * -maxdepth 0 -type d -printf " %p") + +export JAVA_HOME=/opt/jdk +export JDK_HOME=$JAVA_HOME +export M2_HOME=/opt/maven + +bye_bye() { + cd $OLD_PATH + exit $1 +} + +print_usage_and_exit() { + echo "-----------------------------------------------------------------------------------" + echo "usage $(basename $0) [-h] [-b] [-d] [-k] [-m extraBuildParameters] [-r svnRevision] deployType" + echo " -h show usage and exit" + echo " -b for batch mode (no question asked)" + echo " -d for dryRun mode (nothing is deployed)" + echo " -k to keep incoming project version (do not transform version using the svn revision)" + echo " -m extraBuildParameters (add extra parameters to maven build)" + echo " -r svnRevision (update svn to a specific revision, by default use HEAD)" + echo " deployType type of deploy to do (must be one amoung [$DEPLOY_TYPES])" + echo "" + echo "example: $(basename $0) -b -m\"-DperformRelease -Preporting\" -r101010 latest" + echo "-----------------------------------------------------------------------------------" + + bye_bye $1 +} + +test_ok_or_bye_bye() { + if [ $1 -eq 1 ]; then + echo "KO" + echo "$2 (see at $LOG_FILE)" + bye_bye 1 + else + echo "OK" + fi +} +echo -n "0/4 Check options and prepare svn..." + +MAVEN_BUILD="clean install -Pcollect-deploy-files" +SVN_REV="HEAD" +KEEP_VERSION=0 # 0 when transform version using svn revision, 1 keep incoming version +BATCH_MODE=0 # 0 when interactive, 1 when batch mode +DRY_RUN=0 # 0 when execute, 1 when dry run +while getopts ":m:r:hbdk" opt; do + case $opt in + h) + echo "OK" + print_usage_and_exit 0 + ;; + b) + BATCH_MODE=1 + ;; + d) + DRY_RUN=1 + ;; + k) + KEEP_VERSION=1 + ;; + m) + MAVEN_BUILD="$MAVEN_BUILD $OPTARG" + ;; + r) + SVN_REV="$OPTARG" + ;; + \?) + echo "KO" + echo "Invalid option: -$OPTARG" >&2 + print_usage_and_exit 1 + ;; + :) + echo "KO" + echo "Option -$OPTARG requires an argument." >&2 + print_usage_and_exit 1 + ;; + esac + shift $((OPTIND-1)) +done + +# must have a last mandatory parameter +if [ ! $# -eq 1 ]; then + echo "KO" + echo "Mandatory deploy type not given" + print_usage_and_exit 1 +fi +DEPLOY_TYPE="$1" + +# check deploy type exist +if [ ! -d $DEPLOY_TYPE ]; then + echo "KO" + echo "Could not find deploy type $DEPLOY_TYPES (available: $DEPLOY_TYPES)" + bye_bye 1 +fi + +# check deploy structure +cd $DEPLOY_TYPE +if [ ! -f deploy ]; then + echo "KO" + echo "Could not find $DEPLOY_TYPE/deploy file" + bye_bye 1 +fi +if [ ! -f config ]; then + echo "KO" + echo "Could not find $DEPLOY_TYPE/config file" + bye_bye 1 +fi +if [ ! -d svn ]; then + echo "Could not find $DEPLOY_TYPE/svn directory" + bye_bye 1 +fi + +cd svn + +# revert svn +svn revert -R . --non-interactive > /dev/null + +# update svn +svn up -r$SVN_REV --non-interactive > /dev/null + +# get subversion revision +REV=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` + +# get project version +VERSION=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` + +# get new version +if [ $KEEP_VERSION -eq 1 ]; then + NEW_VERSION=$VERSION +else + NEW_VERSION=`${M2_HOME}/bin/mvn -N helper:transform-project-version -Dhelper.newVersionPattern="#V-rev#R" -Dhelper.revision=$REV -DhelperPluginVersion=2.0 -Dhelper.versionKey=deployKey help:evaluate -Dexpression=deployKey | grep -v "\[" | grep "-rev" | grep -v "Download"` +fi + +echo "OK" +echo "----------------------------------------------------------" +echo "--- Deploy summary ---------------------------------------" +echo "----------------------------------------------------------" +echo "- application = $APPLICATION_NAME" +echo "- deployType = $DEPLOY_TYPE" +if [ $BATCH_MODE -eq 1 ]; then + echo "- batchMode = ON" +fi +if [ $DRY_RUN -eq 1 ]; then + echo "- dryRun = ON" +fi +if [ $KEEP_VERSION -eq 1 ]; then + echo "- keepVersion = ON" +fi +echo "- revision detected = $REV" +echo "- version detected = $VERSION" +echo "- new version = $NEW_VERSION" +echo "- build parameters = $MAVEN_BUILD" +echo "----------------------------------------------------------" + +if [ $BATCH_MODE -eq 0 ]; then + # ask user to confirm + echo -n "Accept the change ? [Y/n]" + read r + if [ ! -z "$r" -o "$r" = "Y" ]; then + echo "User cancel operation" + bye_bye 1 + fi +fi + +# log file +LOG_FILE=/tmp/deploy-to-demo-$APPLICATION_NAME-$DEPLOY_TYPE.log + +# change version in pom.xml +echo -n "1/4 Change to version $NEW_VERSION..." +if [ $KEEP_VERSION -eq 1 ]; then + echo "OK (keep version, skip this step)" +else + ${M2_HOME}/bin/mvn versions:set -DnewVersion=$NEW_VERSION > $LOG_FILE + test_ok_or_bye_bye $? "Error while executing '${M2_HOME}/bin/mvn versions:set -DnewVersion=$NEW_VERSION'" +fi + +# build application +echo -n "2/4 Build application..." +${M2_HOME}/bin/mvn $MAVEN_BUILD > $LOG_FILE +test_ok_or_bye_bye $? "Error while executing '${M2_HOME}/bin/mvn $MAVEN_BUILD'" + +cd .. + +echo -n "3/4 Deploy to demo..." + +if [ $DRY_RUN -eq 1 ]; then + echo "OK (dry run, skip this step)" +else + + # build the curl deploy options + DEPLOY_ARGS="-s " + for i in $(cat deploy); do + DEPLOY_ARGS="$DEPLOY_ARGS -F \"$i\""; + done + for i in $(cat svn/target/collect-deploy-files.txt); do + DEPLOY_ARGS="$DEPLOY_ARGS -F \"APP_WAR=@$i\"" + continue + done + + # Create a file to execute the curl command (pb with @ in bash execution...) + DEPLOY_ARGS="$DEPLOY_ARGS http://demo-ng.codelutin.com/deploy.cgi" + DEPLOY_COMMAND=/tmp/deploy-to-demo-curl-$APPLICATION_NAME.sh + cat << EOF > $DEPLOY_COMMAND + curl $DEPLOY_ARGS +EOF + + chmod +x $DEPLOY_COMMAND + + # execute the curl command + cat $DEPLOY_COMMAND > $LOG_FILE + . $DEPLOY_COMMAND >> $LOG_FILE + + # check there is a Deploy success in response" + if [ $? -eq 0 ]; then + grep "Deploy success" $LOG_FILE > /dev/null + fi + test_ok_or_bye_bye $? "Could not deploy to demo" +fi + +# revert any change +echo -n "4/4 Revert local modifications..." +svn revert -R svn > /dev/null +echo "OK" + +bye_bye 0 Property changes on: scripts/maven-release/legacy/deploy-demo.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-sandra-to-glon.sh =================================================================== --- scripts/maven-release/legacy/deploy-sandra-to-glon.sh (rev 0) +++ scripts/maven-release/legacy/deploy-sandra-to-glon.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,95 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +#cd /home/maven-release/projets/glon/sandra + +# get application name +applicationName=sandra +# first do a up +svn up +# get web module name to deploy +webModule=sandra-ear +jarModule=sandra-scheduler +buildParameters="clean install -Pno-tests -Passembly-profile $@" + +# get subversion revision +rev=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` +# get project version +version=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` +# get version suffix (Snapshot or not snapshot) +versionSuffix="" +echo $version | grep -e "-SNAPSHOT" > /dev/null +if [ $? -eq 0 ]; then + versionSuffix="-SNAPSHOT" +fi +# get new version to apply +newVersion=`echo $version | cut -d'-' -f1`"-rev-$rev$versionSuffix" +echo "application $applicationName, webmodule $webModule" +echo "revision detected : $rev - version detected : $version" +echo -n "new version = $newVersion, do the change ? [Y/n]" +read r + +if [ -z "$r" -o "$r" = "Y" ]; then + + logFile=/tmp/deploy-to-glon-$webModule.log + + # change version + echo -n "1/6 Change to version $newVersion..." + mvn versions:set -DnewVersion=$newVersion > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn versions:set -DnewVersion=$newVersion' (see at $logFile)" + else + echo "OK" + # build application + echo -n "2/6 Build application mvn $buildParameters" + mvn $buildParameters > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn $buildParameters' (see at $logFile)" + else + echo "OK" + + # copy war to glon and (if ok) launch deploy.sh script from application location on glon (var/local/xxx) + warLocation="$webModule/target/$webModule-$newVersion.ear" + warDestination="/data/sandra/$webModule/" + echo -n "3/6 Deploy $warLocation to $warDestination..." + scp $warLocation codelutin@glon.codelutin.com:$warDestination > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Could not deploy ear file to glon (see at $logFile)" + else + echo "OK" + + # copy jar to glon and (if ok) launch deploy.sh script from application location on glon (var/local/xxx) + assemblyLocation="$jarModule/target/$jarModule-$newVersion-bin.zip" + assemblyDestination="/data/sandra/$jarModule/" + echo -n "4/6 Deploy $assemblyLocation to $assemblyDestination..." + scp $assemblyLocation codelutin@glon.codelutin.com:$assemblyDestination > $logFile + if [ $? -eq 1 ]; then + echo "KO" + echo "Could not deploy assembly to glon (see at $logFile)" + else + echo "OK" + scriptToExecute="( cd /data/sandra/bin ; ./deploy.sh $newVersion )" + echo -n "5/6 Execute on glon : $scriptToExecute..." + (cd $webModule ; mvn org.nuiton:helper-maven-plugin:1.4:execute-remote-command -Dhelper.repositoryId=glon.codelutin.com -Dhelper.repositoryUrl=scpexe://glon.codelutin.com -Dhelper.command="$scriptToExecute" > $logFile) + if [ $? -eq 1 ]; then + echo "KO" + echo"Could not execute script $scriptToExecute on glon (see at $logFile)" + else + echo "OK" + fi + fi + fi + fi + fi + + # revert any change + echo -n "6/6 Revert local modifications..." + svn st | xargs svn revert > /dev/null + echo "OK" +fi Property changes on: scripts/maven-release/legacy/deploy-sandra-to-glon.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-BETA.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-BETA.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-BETA.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,118 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +# checking usage + +if [ $# -lt 1 ]; then + echo "usage : $0 applicationName instanceUrl [extra build parameters]" + exit 0 +fi + +# reading and using first command-line arguments +applicationName=$1 +shift 1 + +# reading and using second command-line arguments (instance url) +instanceUrl=$2 + +# remaining arguments are maven build arguments +buildParameters="clean install -Pcollect-deploy-files $@" + +# first do a up +svn up + +# get subversion revision +rev=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` + +# get project version +version=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` + +# get version suffix (Snapshot or not snapshot) +versionSuffix="" + +#echo $version | grep -e "-SNAPSHOT" > /dev/null +echo $version | grep -e "-" > /dev/null +if [ $? -eq 0 ]; then + versionSuffix=`echo $version | sed "s/[^-]*\(-.*\)/\1/"` + #versionSuffix="-SNAPSHOT" +fi + +# dont add revision if SNAPSHOT not found (released version) +revVersionSufix="" +if [ ! -z "$versionSuffix" ]; then + revVersionSufix="-rev-$rev$versionSuffix" + + # get new version to apply + newVersion=`echo $version | cut -d'-' -f1`"$revVersionSufix" + echo "application $applicationName" + #echo "application $applicationName, webmodule $webModule, artifact $artifact" + echo "revision detected : $rev - version detected : $version" + echo -n "new version = $newVersion, do the change ? [Y/n]" + read r +fi + +if [ -z "$r" -o "$r" = "Y" -o ! -z "$versionSuffix" ]; then + + logFile=/tmp/deploy-to-demo-$applicationName.log + + if [ ! -z "$versionSuffix" ]; then + # change version in pom.xml + echo -n "1/5 Change to version $newVersion..." + mvn versions:set -DnewVersion=$newVersion > $logFile + else + echo -n "1/5 $version is a released version, nothing to do..." + fi + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn versions:set -DnewVersion=$newVersion' (see at $logFile)" + else + echo "OK" + + # build application + echo -n "2/5 Build application mvn $buildParameters" + mvn $buildParameters > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn $buildParameters' (see at $logFile)" + else + echo "OK" + + # copy files to demo + remoteDir=/var/local/$applicationName + + echo -n "3/5 Deploy to $remoteDir..." + + for f in $(cat target/collect-deploy-files.txt); do + scp $f root@$instanceUrl:$remoteDir > $logFile + done + + if [ $? -eq 1 ]; then + echo "KO" + echo "Could not deploy to demo (see at $logFile)" + else + echo "OK" + + # find and execute the deploy.sh file specific to the application + scriptToExecute="( cd /var/local/$applicationName ; ./deploy.sh $newVersion )" + echo -n "4/5 Execute on demo : $scriptToExecute..." + mvn org.nuiton:helper-maven-plugin:1.4:execute-remote-command -N -Dhelper.repositoryId=$instanceUrl -Dhelper.repositoryUrl=scpexe://$instanceUrl -Dhelper.command="$scriptToExecute" > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo"Could not execute script $scriptToExecute on demo (see at $logFile)" + else + echo "OK" + fi + fi + fi + fi + + # revert any change + echo -n "5/5 Revert local modifications..." + svn st | xargs svn revert > /dev/null + echo "OK" + +fi + Property changes on: scripts/maven-release/legacy/deploy-to-BETA.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-demo-BETA.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-demo-BETA.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-demo-BETA.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,7 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +applicationName=$(basename `pwd`) # the D directory, on demo server, like /var/local/D/... +instanceUrl="demo.codelutin.com" + +deploy-to-BETA.sh $applicationName $instanceUrl $@ Property changes on: scripts/maven-release/legacy/deploy-to-demo-BETA.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-demo-ng.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-demo-ng.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-demo-ng.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,7 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +applicationName=$(cd .. ; basename `pwd`) # the D directory, on demo server, like /var/local/D/... + +deploy-to-demo2-ng.sh $applicationName $@ + \ No newline at end of file Property changes on: scripts/maven-release/legacy/deploy-to-demo-ng.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-demo-ng2.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-demo-ng2.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-demo-ng2.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,97 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +# checking usage + +if [ $# -lt 1 ]; then + echo "usage : $0 applicationName [extra build parameters]" + exit 0 +fi + +# reading and using first command-line arguments + +applicationName=$1 +shift 1 + +# remaining arguments are maven build arguments +buildParameters="clean install -Pcollect-deploy-files $@" + +# first do a up +svn up + +# get subversion revision +rev=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` + +# get project version +version=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` + +# get new version +newVersion=`mvn -N helper:transform-project-version -Dhelper.newVersionPattern="#V-rev#R" -Dhelper.revision=$rev -DhelperPluginVersion=2.0 -Dhelper.versionKey=deployKey help:evaluate -Dexpression=deployKey | grep -v "\[" | grep "-rev" | grep -v "Download"` + +echo "application $applicationName" +#echo "application $applicationName, webmodule $webModule, artifact $artifact" +echo "revision detected : $rev - version detected : $version" +echo -n "new version = $newVersion, do the change ? [Y/n]" +read r + +if [ -z "$r" -o "$r" = "Y" ]; then + + logFile=/tmp/deploy-to-demo-$applicationName.log + + # change version in pom.xml + echo -n "1/5 Change to version $newVersion..." + mvn versions:set -DnewVersion=$newVersion > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn versions:set -DnewVersion=$newVersion' (see at $logFile)" + else + echo "OK" + + # build application + echo -n "2/5 Build application mvn $buildParameters" + mvn $buildParameters > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn $buildParameters' (see at $logFile)" + else + echo "OK" + + # copy files to demo + remoteDir=/var/local/$applicationName + + echo -n "3/5 Deploy to $remoteDir..." + + for f in $(cat target/collect-deploy-files.txt); do + scp $f root@demo.codelutin.com:$remoteDir > $logFile + done + + if [ $? -eq 1 ]; then + echo "KO" + echo "Could not deploy to demo (see at $logFile)" + else + echo "OK" + + # find and execute the deploy.sh file specific to the application + scriptToExecute="( cd /var/local/$applicationName ; ./deploy.sh $newVersion )" + echo -n "4/5 Execute on demo : $scriptToExecute..." + mvn org.nuiton:helper-maven-plugin:1.4:execute-remote-command -N -Dhelper.repositoryId=demo.codelutin.com -Dhelper.repositoryUrl=scpexe://demo.codelutin.com -Dhelper.command="$scriptToExecute" > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo"Could not execute script $scriptToExecute on demo (see at $logFile)" + else + echo "OK" + fi + fi + fi + fi + + # revert any change + echo -n "5/5 Revert local modifications..." + svn st | xargs svn revert > /dev/null + echo "OK" + +fi + Property changes on: scripts/maven-release/legacy/deploy-to-demo-ng2.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-demo.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-demo.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-demo.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,7 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +applicationName=$(basename `pwd`) # the D directory, on demo server, like /var/local/D/... + +deploy-to-demo2.sh $applicationName $@ + \ No newline at end of file Property changes on: scripts/maven-release/legacy/deploy-to-demo.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-demo2-ng.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-demo2-ng.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-demo2-ng.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,107 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +# checking usage + +if [ $# -lt 2 ]; then + echo "usage : $0 applicationName deployType(latest, staging, stable) [extra build parameters]" + exit 0 +fi + +# reading and using first command-line arguments + +applicationName=$1 +shift 1 + +deployType=$1 +shift 1 + +deployFile=../deploy-$deployType + +if [ ! -f $deployFile ]; then + echo "Can't find deploy file at $deployFile" + exit 1 +fi + + +# remaining arguments are maven build arguments +buildParameters="clean install -Pcollect-deploy-files $@" + +# first do a up +svn up > /dev/null + +# get subversion revision +rev=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` + +# get project version +version=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` + +# get new version +newVersion=`mvn -N helper:transform-project-version -Dhelper.newVersionPattern="#V-rev#R" -Dhelper.revision=$rev -DhelperPluginVersion=2.0 -Dhelper.versionKey=deployKey help:evaluate -Dexpression=deployKey | grep -v "\[" | grep "-rev" | grep -v "Download"` + +echo "application $applicationName - deployType $deployType" +echo "revision detected : $rev - version detected : $version" +echo -n "new version = $newVersion, do the change ? [Y/n]" +read r + +if [ -z "$r" -o "$r" = "Y" ]; then + + logFile=/tmp/deploy-to-demo-$applicationName.log + + # change version in pom.xml + echo -n "1/4 Change to version $newVersion..." + mvn versions:set -DnewVersion=$newVersion > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn versions:set -DnewVersion=$newVersion' (see at $logFile)" + else + echo "OK" + + # build application + echo -n "2/4 Build application mvn $buildParameters" + mvn $buildParameters > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn $buildParameters' (see at $logFile)" + else + echo "OK" + echo -n "3/4 Deploy to demo (using $deployFile)..." + + deploy_args="" + for i in $(cat $deployFile); do + deploy_args="$deploy_args -F \"$i\""; + done + for i in $(cat target/collect-deploy-files.txt); do + deploy_args="$deploy_args -F \"APP_WAR=@$i\"" + continue + done + + deploy_args="$deploy_args http://demo-ng.codelutin.com/deploy.cgi" + + #echo "Deploy url: $deploy_args" + + # use an external file to launch the curl command otherwise, can't make it work :( + curl_file=/tmp/deploy-to-demo-curl-$applicationName.sh + cat << EOF > $curl_file + curl $deploy_args +EOF + chmod +x $curl_file + . $curl_file + if [ $? -eq 1 ]; then + echo "KO" + echo "Could not deploy to demo (see at $logFile)" + else + echo "OK" + fi + fi + fi + + # revert any change + echo -n "4/4 Revert local modifications..." + svn st | xargs svn revert > /dev/null + echo "OK" + +fi + Property changes on: scripts/maven-release/legacy/deploy-to-demo2-ng.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-demo2.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-demo2.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-demo2.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,97 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +# checking usage + +if [ $# -lt 1 ]; then + echo "usage : $0 applicationName [extra build parameters]" + exit 0 +fi + +# reading and using first command-line arguments + +applicationName=$1 +shift 1 + +# remaining arguments are maven build arguments +buildParameters="clean install -Pcollect-deploy-files $@" + +# first do a up +svn up + +# get subversion revision +rev=`svn info . | grep "vision" | head -n 1 | cut -d':' -f2 | sed 's/^ *//g'` + +# get project version +version=`xmlstarlet sel -N "p=http://maven.apache.org/POM/4.0.0" -t -v "/p:project/p:version" pom.xml` + +# get new version +newVersion=`mvn -N helper:transform-project-version -Dhelper.newVersionPattern="#V-rev#R" -Dhelper.revision=$rev -DhelperPluginVersion=2.0 -Dhelper.versionKey=deployKey help:evaluate -Dexpression=deployKey | grep -v "\[" | grep "-rev" | grep -v "Download"` + +echo "application $applicationName" +#echo "application $applicationName, webmodule $webModule, artifact $artifact" +echo "revision detected : $rev - version detected : $version" +echo -n "new version = $newVersion, do the change ? [Y/n]" +read r + +if [ -z "$r" -o "$r" = "Y" ]; then + + logFile=/tmp/deploy-to-demo-$applicationName.log + + # change version in pom.xml + echo -n "1/5 Change to version $newVersion..." + mvn versions:set -DnewVersion=$newVersion > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn versions:set -DnewVersion=$newVersion' (see at $logFile)" + else + echo "OK" + + # build application + echo -n "2/5 Build application mvn $buildParameters" + mvn $buildParameters > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo "Error while executing 'mvn $buildParameters' (see at $logFile)" + else + echo "OK" + + # copy files to demo + remoteDir=/var/local/$applicationName + + echo -n "3/5 Deploy to $remoteDir..." + + for f in $(cat target/collect-deploy-files.txt); do + scp $f root@demo.codelutin.com:$remoteDir > $logFile + done + + if [ $? -eq 1 ]; then + echo "KO" + echo "Could not deploy to demo (see at $logFile)" + else + echo "OK" + + # find and execute the deploy.sh file specific to the application + scriptToExecute="( cd /var/local/$applicationName ; ./deploy.sh $newVersion )" + echo -n "4/5 Execute on demo : $scriptToExecute..." + mvn org.nuiton:helper-maven-plugin:1.4:execute-remote-command -N -Dhelper.repositoryId=demo.codelutin.com -Dhelper.repositoryUrl=scpexe://demo.codelutin.com -Dhelper.command="$scriptToExecute" > $logFile + + if [ $? -eq 1 ]; then + echo "KO" + echo"Could not execute script $scriptToExecute on demo (see at $logFile)" + else + echo "OK" + fi + fi + fi + fi + + # revert any change + echo -n "5/5 Revert local modifications..." + svn st | xargs svn revert > /dev/null + echo "OK" + +fi + Property changes on: scripts/maven-release/legacy/deploy-to-demo2.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-glon-BETA.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-glon-BETA.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-glon-BETA.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,7 @@ +#!/bin/sh +# script to update rev using the pom version + the svn revision + +applicationName=$(basename `pwd`) # the D directory, on demo server, like /var/local/D/... +instanceUrl="glon.codelutin.com" + +deploy-to-BETA.sh $applicationName $instanceUrl $@ Property changes on: scripts/maven-release/legacy/deploy-to-glon-BETA.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/deploy-to-latest.sh =================================================================== --- scripts/maven-release/legacy/deploy-to-latest.sh (rev 0) +++ scripts/maven-release/legacy/deploy-to-latest.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,6 @@ +#!/bin/sh +# script to deploy app to demo latest env + +applicationName=$(cd .. ; basename `pwd`) +deploy-to-demo2-ng.sh $applicationName latest $@ + \ No newline at end of file Property changes on: scripts/maven-release/legacy/deploy-to-latest.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/mavenpom-update.sh =================================================================== --- scripts/maven-release/legacy/mavenpom-update.sh (rev 0) +++ scripts/maven-release/legacy/mavenpom-update.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,60 @@ +#!/bin/bash + +type="$1" +directory="$2" +version="$3" + +message="Update $type to $version." +projetsDirectory=~/projets/$directory + +reset +echo "***********************************************************************" +echo "Commit message : $message" +echo "Parent pom to use : $type - $version" +echo "Directory to scan : $projetsDirectory" + +old=`pwd` + +cd $projetsDirectory +echo "will work in $(pwd)" + +for i in $(ls | grep -v "*.iml"); do + echo "***********************************************************************" + + cd $projetsDirectory + + echo "update project $i" + (cd $i && svn up) + + echo "update pom.xml" + (cd $i && xmlstarlet ed -P -S -N "p=http://maven.apache.org/POM/4.0.0" -u "/p:project/p:parent/p:version" -v $version pom.xml > pom.xml2 && mv pom.xml pom.xml~ && mv pom.xml2 pom.xml) + + cd $i + svn diff pom.xml | grep "@@" + doCommit="$?" + echo "modified ? $doCommit" + cd .. + if [ $doCommit -eq 1 ]; then + echo "Nothing modified on $i/pom" + continue + fi + + r="Y" + echo "file $i/pom was modified" + (cd $i && svn diff pom.xml) + + echo -n "do commit pom.xml ? [Y/n] " + read r + + if [ -z "$r" -o "$r" == "Y" ]; then + + echo "commit $i/pom.xml" + (cd $i ; svn ci pom.xml -m"$message") + else + + echo "revert $i/pom.xml" + (cd $i ; mv pom.xml~ pom.xml) + fi +done + +cd $old Property changes on: scripts/maven-release/legacy/mavenpom-update.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/mmvn.sh =================================================================== --- scripts/maven-release/legacy/mmvn.sh (rev 0) +++ scripts/maven-release/legacy/mmvn.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,34 @@ +# /bin/sh + +FILE=/tmp/mmvn.tmp + +MAIN_DIR=`pwd` + +COMMAND=$1 + +rm -rf "$FILE" + +echo "detects maven projects from directory $MAIN_DIR" + +find $MAIN_DIR -name "pom.xml" -printf %h\\n >> $FILE + +echo -n "will execute command '$COMMAND' on " +echo -n `wc -l < $FILE` +echo " project(s)" + +for i in `cat $FILE` ; do + cd $MAIN_DIR + cd "$i" + echo -n `pwd` + echo -n "..." + eval $COMMAND > /dev/null + result="$?" + if [ $result -eq 1 ]; then + echo "KO" + else + echo "OK" + fi + +done + +cd $MAIN_DIR Property changes on: scripts/maven-release/legacy/mmvn.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/legacy/svn-update.sh =================================================================== --- scripts/maven-release/legacy/svn-update.sh (rev 0) +++ scripts/maven-release/legacy/svn-update.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,17 @@ +#!/bin/bash + +#type="$1" + +old=`pwd` +reset +for type in $@ ; do + echo "========================================================" + echo "mise a jour de repertoire ~/projets/$type" + cd ~/projets/$type + for i in $(ls | grep -v ".iml" | grep -v "meta-pom*"| grep -v "*~"| grep -v "tesdir"); do + echo $i + ( cd $i ; svn up ) + done +done + +cd $old Property changes on: scripts/maven-release/legacy/svn-update.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: scripts/maven-release/mvn-ep.sh =================================================================== --- scripts/maven-release/mvn-ep.sh (rev 0) +++ scripts/maven-release/mvn-ep.sh 2014-01-17 17:18:41 UTC (rev 11) @@ -0,0 +1,18 @@ +#!/bin/sh +# script to encode a password via mvn with no console password + +# file where to read password to encode (by default pass file) +file=pass + +if [ $# -eq 1 ]; then + file=$1 +fi + +if [ ! -f $file ]; then + echo "$file does not exist!" + exit 0 +fi + +mypass=`cat $file` +mvn -ep $mypass +rm -rfv $file Property changes on: scripts/maven-release/mvn-ep.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native