r12 - scripts/maven-release
Author: maven-release Date: 2014-01-17 21:30:17 +0100 (Fri, 17 Jan 2014) New Revision: 12 Url: http://forge.codelutin.com/projects/adminsys/repository/revisions/12 Log: fixes #3653: Mettre en place le script de deploy sur demo via un GAV Added: scripts/maven-release/deploy-to-demo-from-GAV.pom Modified: scripts/maven-release/deploy-to-demo-from-GAV.sh Added: scripts/maven-release/deploy-to-demo-from-GAV.pom =================================================================== --- scripts/maven-release/deploy-to-demo-from-GAV.pom (rev 0) +++ scripts/maven-release/deploy-to-demo-from-GAV.pom 2014-01-17 20:30:17 UTC (rev 12) @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Tutti + %% + Copyright (C) 2014 Code Lutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.codelutin</groupId> + <artifactId>deploy-to-demo-from-GAV</artifactId> + <version>1.0</version> + <packaging>pom</packaging> + + <inceptionYear>2014</inceptionYear> + <organization> + <name>Code Lutin</name> + <url>http://www.codelutin.com/</url> + </organization> + + <licenses> + <license> + <name>General Public License (GPL)</name> + <url>http://www.gnu.org/licenses/gpl.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + + <developers> + <developer> + <id>chemit</id> + <name>Tony Chemit</name> + <email>chemit at codelutin dot com</email> + <organization>CodeLutin</organization> + <organizationUrl>http://www.codelutin.com</organizationUrl> + <roles> + <role>developer</role> + </roles> + <timezone>Europe/Paris</timezone> + </developer> + </developers> + + <properties> + <packaging>war</packaging> + <classifier/> + </properties> + + <build> + + <defaultGoal>validate</defaultGoal> + + <pluginManagement> + <plugins> + + <plugin> + <artifactId>maven-enforcer-plugin</artifactId> + <version>1.3.1</version> + </plugin> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.8</version> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + <plugin> + <artifactId>maven-enforcer-plugin</artifactId> + <executions> + <execution> + <id>check-properties</id> + <goals> + <goal>enforce</goal> + </goals> + <phase>validate</phase> + <configuration> + <rules> + <requireProperty> + <property>groupId</property> + <message>You must set a groupId property!</message> + </requireProperty> + <requireProperty> + <property>artifactId</property> + <message>You must set a artifactId property!</message> + </requireProperty> + <requireProperty> + <property>version</property> + <message>You must set a version property!</message> + </requireProperty> + <requireProperty> + <property>file</property> + <message>You must set a file property!</message> + </requireProperty> + </rules> + <ignoreCache>true</ignoreCache> + <failFast>true</failFast> + <fail>true</fail> + + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>get-war</id> + <goals> + <goal>get</goal> + </goals> + <phase>validate</phase> + <configuration> + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <destination>${file}</destination> + <packaging>${packaging}</packaging> + <classifier>${classifier}</classifier> + <transitive>false</transitive> + <remoteRepositories> + http://nexus.nuiton.org/nexus/content/repositories/other-releases + </remoteRepositories> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> Modified: scripts/maven-release/deploy-to-demo-from-GAV.sh =================================================================== --- scripts/maven-release/deploy-to-demo-from-GAV.sh 2014-01-17 17:18:41 UTC (rev 11) +++ scripts/maven-release/deploy-to-demo-from-GAV.sh 2014-01-17 20:30:17 UTC (rev 12) @@ -1,5 +1,6 @@ #!/bin/sh -# script to update rev using the pom version + the svn revision +# to deploy a application to demo using a GAV +# OLD_PATH=$(pwd) APPLICATION_NAME=$(basename $OLD_PATH) @@ -17,16 +18,19 @@ print_usage_and_exit() { echo "-----------------------------------------------------------------------------------" - echo "usage $(basename $0) [-h] [-b] [-d] [-k] [-m extraBuildParameters] [-r svnRevision] deployType" + echo "usage $(basename $0) [-h] [-b] [-d] [-c classifier] [-p packaging] [-e deployFile] -g groupId -a artifactId -v version 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 " -c optional classifier of war to grab" + echo " -p optional packaging, if not set will use war" + echo " -e optional deploy file to use, if not set will use deploy (the file must exists in $DEPLOY_TYPE directory)" + echo " -g groupId groupId of war to collect" + echo " -a artifactId artifactId of war to collect" + echo " -v version version of war to collect" 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 "example: $(basename $0) -b -s cerqual-nexus-repository -g fr.cerqual -a nflogement-extranet-web -v 1.1.5 latest" echo "-----------------------------------------------------------------------------------" bye_bye $1 @@ -41,14 +45,18 @@ 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 +echo -n "1/3 Check and prepare options..." 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 +GROUP_ID= +ARTIFACT_ID= +VERSION= +PACKAGING=war +CLASSIFIER= +DEPLOY_FILE + +while getopts ":g:a:v:c:p:e:hbd" opt; do case $opt in h) echo "OK" @@ -60,15 +68,24 @@ d) DRY_RUN=1 ;; - k) - KEEP_VERSION=1 + g) + GROUP_ID=$OPTARG ;; - m) - MAVEN_BUILD="$MAVEN_BUILD $OPTARG" + a) + ARTIFACT_ID=$OPTARG ;; - r) - SVN_REV="$OPTARG" + v) + VERSION=$OPTARG + ;; + p) + PACKAGING=$OPTARG ;; + c) + CLASSIFIER=$OPTARG + ;; + e) + DEPLOY_FILE=$OPTARG + ;; \?) echo "KO" echo "Invalid option: -$OPTARG" >&2 @@ -100,9 +117,9 @@ # check deploy structure cd $DEPLOY_TYPE -if [ ! -f deploy ]; then +if [ ! -f $DEPLOY_FILE ]; then echo "KO" - echo "Could not find $DEPLOY_TYPE/deploy file" + echo "Could not find $DEPLOY_TYPE/$DEPLOY_FILE file" bye_bye 1 fi if [ ! -f config ]; then @@ -110,58 +127,36 @@ 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 +FILE=$GROUP_ID-$ARTIFACT_ID-$CLASSIFIER-$VERSION.$PACKAGING -# 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" +echo "- application = $APPLICATION_NAME" +echo "- deployType = $DEPLOY_TYPE" +echo "- GAV = $GROUP_ID:$ARTIFACT_ID:$PACKAGING:$VERSION" if [ $BATCH_MODE -eq 1 ]; then - echo "- batchMode = ON" + echo "- batchMode = ON" fi if [ $DRY_RUN -eq 1 ]; then - echo "- dryRun = ON" + echo "- dryRun = ON" fi -if [ $KEEP_VERSION -eq 1 ]; then - echo "- keepVersion = ON" +if [ ! "$CLASSIFIER" = "" ]; then + echo "- classifier = $CLASSIFIER" fi -echo "- revision detected = $REV" -echo "- version detected = $VERSION" -echo "- new version = $NEW_VERSION" -echo "- build parameters = $MAVEN_BUILD" +echo "- file = $DEPLOY_TYPE/$FILE" +echo "- deploy file = $DEPLOY_TYPE/$DEPLOY_FILE" + + 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 + if [ ! -z "$r" -o "$r" = "Y" -o "$r" = "y" ]; then echo "User cancel operation" bye_bye 1 fi @@ -170,41 +165,28 @@ # 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 +# get war to deploy +echo -n "2/3 Get war $FILE to deploy..." +MVN_OPTIONS="-DgroupId=$GROUP_ID -DartifactId=$ARTIFACT_ID -Dversion=$VERSION -DserverId=$SERVER_ID -Dfile=$FILE -Dpackaging=$PACKAGING -Dclassifier=$CLASSIFIER" +${M2_HOME}/bin/mvn -f ~/bin/deploy-to-demo-from-GAV.pom $MVN_OPTIONS > $LOG_FILE +test_ok_or_bye_bye $? "Error while executing '${M2_HOME}/bin/mvn $MVN_OPTIONS ..." -# 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'" +echo -n "3/3 Deploy to demo..." -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 + for i in $(cat $DEPLOY_FILE); 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 + DEPLOY_ARGS="$DEPLOY_ARGS -F \"APP_WAR=@$FILE\"" # 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 + DEPLOY_COMMAND=/tmp/deploy-to-demo-curl-$APPLICATION_NAME-$DEPLOY_TYPE.sh cat << EOF > $DEPLOY_COMMAND curl $DEPLOY_ARGS EOF @@ -222,9 +204,4 @@ 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
participants (1)
-
maven-releaseļ¼ users.forge.codelutin.com