Author: nickboldt
Date: 2011-07-29 19:07:55 -0400 (Fri, 29 Jul 2011)
New Revision: 33379
Modified:
trunk/build/publish.sh
Log:
support both local publishing and user@remote publishing
Modified: trunk/build/publish.sh
===================================================================
--- trunk/build/publish.sh 2011-07-29 22:53:27 UTC (rev 33378)
+++ trunk/build/publish.sh 2011-07-29 23:07:55 UTC (rev 33379)
@@ -31,9 +31,6 @@
# for JBDS, use DESTINATION=/qa/services/http/binaries/RHDS
if [[ $DESTINATION == "" ]]; then
DESTINATION="tools@filemgmt.jboss.org:/downloads_htdocs/tools"; fi
-# if no user@hostname, add it for use with sftp (synlink creation & dir
moves/deletes)
-DESTINATIONREDUX="$DESTINATION"; if [[ ${DESTINATION##*@*:*} == ${DESTINATION}
]]; then DESTINATIONREDUX="hudson@"`hostname -f`":${DESTINATION}"; fi
-
# internal destination mirror, for file:// access (instead of http://)
if [[ $INTRNALDEST == "" ]]; then
INTRNALDEST="/home/hudson/static_build_env/jbds/"; fi
@@ -270,11 +267,15 @@
echo "<meta http-equiv=\"refresh\"
content=\"0;url=${BUILD_ID}-H${BUILD_NUMBER}/\">" >
/tmp/latestBuild.html
if [[ ${PUBLISHPATHSUFFIX} ]]; then
date; rsync -arzq --delete ${STAGINGDIR}/*
$DESTINATION/builds/nightly/${PUBLISHPATHSUFFIX}/${BUILD_ID}-H${BUILD_NUMBER}/
- echo -e "rm latest\nln ${BUILD_ID}-H${BUILD_NUMBER} latest" | sftp
${DESTINATIONREDUX}/builds/nightly/${PUBLISHPATHSUFFIX}/
+ # sftp only works with user@server, not with local $DESTINATIONS, so use rsync to
push symlink instead
+ # echo -e "rm latest\nln ${BUILD_ID}-H${BUILD_NUMBER} latest" | sftp
${DESTINATIONREDUX}/builds/nightly/${PUBLISHPATHSUFFIX}/
+ pushd /tmp >/dev/null; ln -s ${BUILD_ID}-H${BUILD_NUMBER} latest; rsync -l latest
${DESTINATION}/builds/nightly/${PUBLISHPATHSUFFIX}/; rm -f latest; popd >/dev/null
date; rsync -arzq --delete /tmp/latestBuild.html
$DESTINATION/builds/nightly/${PUBLISHPATHSUFFIX}/
else
date; rsync -arzq --delete /tmp/latestBuild.html
$DESTINATION/builds/nightly/${JOBNAMEREDUX}/
- echo -e "rm latest\nln ${BUILD_ID}-H${BUILD_NUMBER} latest" | sftp
${DESTINATIONREDUX}/builds/nightly/${JOBNAMEREDUX}/
+ # sftp only works with user@server, not with local $DESTINATIONS, so use rsync to
push symlink instead
+ # echo -e "rm latest\nln ${BUILD_ID}-H${BUILD_NUMBER} latest" | sftp
${DESTINATIONREDUX}/builds/nightly/${JOBNAMEREDUX}/
+ pushd /tmp >/dev/null; ln -s ${BUILD_ID}-H${BUILD_NUMBER} latest; rsync -l latest
${DESTINATION}/builds/nightly/${JOBNAMEREDUX}/; rm -f latest; popd >/dev/null
date; rsync -arzq --delete ${STAGINGDIR}/*
$DESTINATION/builds/nightly/${JOBNAMEREDUX}/${BUILD_ID}-H${BUILD_NUMBER}/
fi
rm -f /tmp/latestBuild.html
@@ -305,21 +306,35 @@
echo -e "mkdir ${JOB_NAME}" $DESTINATION/builds/staging.previous/
echo -e "mkdir ${JOB_NAME}.2" $DESTINATION/builds/staging.previous/
- # purge contents of /builds/staging.previous/${JOB_NAME}.2 and remove empty dir
- mkdir -p /tmp/${JOB_NAME}.2
- rsync -arzq --delete /tmp/${JOB_NAME}.2 $DESTINATION/builds/staging.previous/
- echo -e "rmdir ${JOB_NAME}.2" | sftp
$DESTINATIONREDUX/builds/staging.previous/
- rmdir /tmp/${JOB_NAME}.2
+ if [[ ${DESTINATION##*@*:*} == "" ]]; then # user@server, do remote op
+ # purge contents of /builds/staging.previous/${JOB_NAME}.2 and remove empty dir
+ mkdir -p /tmp/${JOB_NAME}.2
+ rsync -arzq --delete /tmp/${JOB_NAME}.2 $DESTINATION/builds/staging.previous/
+ echo -e "rmdir ${JOB_NAME}.2" | sftp $DESTINATION/builds/staging.previous/
+ rmdir /tmp/${JOB_NAME}.2
- # move contents of /builds/staging.previous/${JOB_NAME} into
/builds/staging.previous/${JOB_NAME}.2
- echo -e "rename ${JOB_NAME} ${JOB_NAME}.2" | sftp
$DESTINATIONREDUX/builds/staging.previous/
+ # move contents of /builds/staging.previous/${JOB_NAME} into
/builds/staging.previous/${JOB_NAME}.2
+ echo -e "rename ${JOB_NAME} ${JOB_NAME}.2" | sftp
$DESTINATION/builds/staging.previous/
- # move contents of /builds/staging/${JOB_NAME} into
/builds/staging.previous/${JOB_NAME}
- echo -e "rename ${JOB_NAME} ../staging.previous/${JOB_NAME}" | sftp
$DESTINATIONREDUX/builds/staging/
+ # move contents of /builds/staging/${JOB_NAME} into
/builds/staging.previous/${JOB_NAME}
+ echo -e "rename ${JOB_NAME} ../staging.previous/${JOB_NAME}" | sftp
$DESTINATION/builds/staging/
- # move contents of /builds/staging/${JOB_NAME}.next into /builds/staging/${JOB_NAME}
- echo -e "rename ${JOB_NAME}.next ${JOB_NAME}" | sftp
$DESTINATIONREDUX/builds/staging/
+ # move contents of /builds/staging/${JOB_NAME}.next into /builds/staging/${JOB_NAME}
+ echo -e "rename ${JOB_NAME}.next ${JOB_NAME}" | sftp
$DESTINATION/builds/staging/
+ else # work locally
+ # purge contents of /builds/staging.previous/${JOB_NAME}.2 and remove empty dir
+ rm -fr $DESTINATION/builds/staging.previous/${JOB_NAME}.2/
+ # move contents of /builds/staging.previous/${JOB_NAME} into
/builds/staging.previous/${JOB_NAME}.2
+ mv $DESTINATION/builds/staging.previous/${JOB_NAME}
$DESTINATION/builds/staging.previous/${JOB_NAME}.2
+
+ # move contents of /builds/staging/${JOB_NAME} into
/builds/staging.previous/${JOB_NAME}
+ mv $DESTINATION/builds/staging/${JOB_NAME}
$DESTINATION/builds/staging.previous/${JOB_NAME}
+
+ # move contents of /builds/staging/${JOB_NAME}.next into /builds/staging/${JOB_NAME}
+ mv $DESTINATION/builds/staging/${JOB_NAME}.next
$DESTINATION/builds/staging/${JOB_NAME}
+ fi
+
# generate 2 ${STAGINGDIR}/all/composite*.xml files which will point at:
# /builds/staging/${JOB_NAME}/all/repo/
# /builds/staging.previous/${JOB_NAME}/all/repo/
Show replies by date