Author: tchemit Date: 2014-06-08 12:33:39 +0200 (Sun, 08 Jun 2014) New Revision: 87 Url: http://forge.codelutin.com/projects/adminsys/repository/revisions/87 Log: refs #4057 script pour generer les sites maven pour chaque version Added: scripts/redmine-tools/deploy-git-sites.sh Added: scripts/redmine-tools/deploy-git-sites.sh =================================================================== --- scripts/redmine-tools/deploy-git-sites.sh (rev 0) +++ scripts/redmine-tools/deploy-git-sites.sh 2014-06-08 10:33:39 UTC (rev 87) @@ -0,0 +1,119 @@ +#! /bin/bash + +############################################################ +# To deploy all sites for a project (git version) +# +# usage deploy-git-sites.sh forge projectId versionFile +# +# forge is forge domain name (nuiton.org|chorem.org|codelutin.com) +# +# projectId is the redmine projectId +# +# versionFile contains one line by version in this format +# +# version1:releaseDate +# version2:releaseDate +# ... +# +# An ouput file is /tmp/changelog-$projectId.html which contains +# the html fragment to put in the changelog file on the +# top of the project. +# +############################################################ +## History +# 2014-06-08 chemit@codelutin.com +# - initial version +# +############################################################ + +if [ ! $# -eq 3 ]; then + echo "usage: $0 forge projectId versionFile" + echo "" + echo "- forge is the forge domain name (nuiton.org|chorem.org|codelutin.com)" + echo "- projectId is the redmine project id " + echo "- versionfile contains all versions of the project, one version per line in this format" + echo " versionId:releaseDate (versionId is the redmine version id)" + echo "" + echo "Produce an output file in /tmp/index-projectId.html to put in changelog page" + exit 1 +fi + +forge=$1 +projectId=$2 +projectFile=$3 +projectId=$(basename $projectFile .versions) +oldPath=$(pwd) + +gitDirectory=/tmp/"$projectId" +rm -rf $gitDirectory +git clone https://git."$forge"/"$projectId".git $gitDirectory + +cd $gitDirectory + +changelogFile=/tmp/changelog-$projectId.html +rm -rf $changelogFile + +while read line ; do + versionId=$(echo $line | cut -d':' -f1) + releaseDate=$(echo $line | cut -d':' -f2) + tagName=$projectId-$versionId + siteUrl=http://doc.$forge/$projectId/$versionId/ + echo "Check if exist $siteUrl (tag name: $tagName)" + response=$(curl -sI $siteUrl | head -1 | grep HTTP | cut -d' ' -f2) + if [ "$response" = "404" ]; then + + echo "Get tag $tagName" + git reset -q --hard "$tagName" + + grep distributionManagement pom.xml &> /dev/null + if [ $? -eq 1 ]; then + + echo "No distributionManagement section in pom, add it" + + xmlstarlet ed -P -L -N "p=http://maven.apache.org/POM/4.0.0" \ + -s "/p:project" -t elem -n "distributionManagement" \ + -s "//p:project/distributionManagement" -t elem -n "site" \ + -s "//p:project/distributionManagement/site" -t elem -n "id" -v "doc.$forge" \ + -s "//p:project/distributionManagement/site" -t elem -n "url" -v "scpexe://doc.$forge/var/lib/redmine-$forge/project-site/$projectId" pom.xml + + else + + 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 distributionManagement/url" + exit 1 + fi + + deployUrl=$deployUrl/$versionId + echo "Change deploy url to $deployUrl" + + xmlstarlet ed -P -L -N "p=http://maven.apache.org/POM/4.0.0" -u "/p:project/p:distributionManagement/p:site/p:id" -v "doc.$forge" -u "/p:project/p:distributionManagement/p:site/p:url" -v "$deployUrl" pom.xml + + fi + + logFile=/tmp/build-site-"$projectId"-"$versionId".log + echo "Build site $tagName (log: $logFile)" + #mvn clean site-deploy -DperformRelease -l $logFile + + else + + echo "$siteUrl already exist, skip site generation" + + fi + + cat << EOF >> $changelogFile + <tr> + <td>$versionId</td> + <td>$releaseDate</td> + <td><a target="site" href="./$versionId">site</a></td> + <td></td> + <td>tag <strong>$projectId-$versionId</strong></td> + </tr> +EOF + +done < $oldPath/$projectFile + +echo "Get changelog in $changelogFile" + +cd $oldPath Property changes on: scripts/redmine-tools/deploy-git-sites.sh ___________________________________________________________________ Added: svn:executable + *