Changes

Jump to: navigation, search

Continuous Integration/proposal

5,257 bytes removed, 18:58, 8 April 2011
Replaced content with ' == Automating The Synchronization of NexJ Server Express External Repository (Oct 6, 2010)== ===Part 1 – Checking for new Change Sets on the Internal Repository=== At…'
<source lang="bash">
#!/bin/bash
==
# script for automating synchronization Automating The Synchronization of # Internal Repoand NexJ Server Express External Repo of NexJ # CDOT - 22/Oct/2010Repository
(Oct 6, 2010)==
#changed to /usr/bin/rm ===Part 1 – Checking for using in cmdPATHnew Change Sets on the Internal Repository===/usr/bin:$PATH
 nexj_home="D:/cygwin/data/hudson/nexj_express"patch="${nexj_home}/patches"src="${nexj_home}/src"doc="${nexj_home}/doc"ANT="${nexj_home}/java/apache-ant-1.7.1/bin/ant"tmpInternal="${nexj_home}/tmpInternal"tmpExternal="${nexj_home}/tmpExternal/core"hgExt="D:/cygwin/home/NexJExpress/External"hgExtURL="https://ossbuild:go_express@cvs-ext.nexj.com/oss/core"hgIntDir="${nexj_home}/hg.nexj.com/core"hgIntURL="D:/cygwin/home/NexJExpress/Internal"  # add this info to At a scheduled time, a process will run that will compare the name current Revision ID of report filereportDate=`date +%Y-%m-%0e-TIME-%H-%M`;# add this info to the name of build and test log filesbuildDate=`date +%Y-%m-%0e`;# flag External Repository to check if there was any error for results that in Hudsonerror=0  # go to the working directory and clean up everythingcd ${nexj_home} 2> /dev/nullif [ $? != 0 ]; then echo "No such directory ${nexj_home}" exit 1fi  #Remove temporary repositoriesif [ -d tmpExternal ]; then rm -r tmpExternal echo "tmpExternal removed"fi  ############################ Working with Internal##########################cd $hgIntDir 2> /dev/nullif [ $? != 0 ]; then mkdir $hgIntDir hg clone -b default $hgIntURL $hgIntDir cd $hgIntDirfi  # Get latest code from internalhg pull -u -b default 2> /dev/nullif [ $? != 0 ]; then echo "hg pull failed for hgIntURL ${hgIntURL}" exit 1fi  # Get latest internal revision numberrevInternal=`hg log -r tip -b default --template '{node}'`echo "Internal Rev $revInternal"if [[ $revInternal =~ "+" ]]; then echo "=========================================" echo "ERROR! Revision $revInternal is not commited yet" echo "=========================================" exit 1fi  ############################ Working with External########################### Get the latest code from external repomkdir -p ${tmpExternal} 2> /dev/nullif [ $? != 0 ]; then echo "could not create ${tmpExternal}" exit 1fi  hg clone ${hgExt} ${tmpExternal} # later will be hg clone ${hgExtURL} ${tmpExternal}if [ $? != 0 ]; then echo "Clone was not successful" exit 1fi  # extract the revision number of latest changeset commited to the External Repocd ${tmpExternal} revExternal=`hg log -r tip | grep rev `if [ $? != 0 ]; then echo "There is no repository availble at ${hgExt}" exit 1fi  # extract the Internal revision number from summaryrevExternal=${revExternal#*revInternal:}echo "External Rev $revExternal"  # report file name is created based on datereport="Report-(${reportDate})"  echo -e "\n" >> $doc/$report.txtif [ $? != 0 ]; then echo "2: No such file $doc/${report}Repository.txt" exit 1fi  echo "REPORT FOR $reportDate" >> $doc/$report.txtecho "========================================" >> $doc/$report.txt  # if If there is no a new change set, end the scriptif [ ${revInternal} == ${revExternal} ]; then echo "There are no new changesets." >> $docrevision/$report.txt echo "========================================" >> $doc/$report.txt cat $doc/$report.txt exit 0fi  cd ${nexj_home}# get the list of the latest changesets since last time committing to the external reporevList=`hg log ${hgIntDir} -r ${revExternal}: --template '{node}\n'`if [ $? != 0 ]; then echo "No repository available at ${hgIntDir}" exit 1fifor rev s in $revList; do if [ ${rev} != ${revExternal} ]; then echo "Revision of hgIntDir is $rev"   cd ${hgIntDir} exPatch=$patch/patch${rev}.patch # if there is any patch with $rev number, remove it if [ -e ${exPatch} ]; then rm ${exPatch} fi   hg export -r ${rev} > ${exPatch} if [ $? != 0 ]; then echo "export was not successful" exit 1 fi # extract hgIntDir's tip summary and add rev number # to the commit summary for tmpExternal Repo sumHgIntDir=`hg log -r $rev --template '{desc}\n'` if [ $? != 0 ]; then echo "No repository available" exit 1 fi sumTmpExternal="${sumHgIntDir}-revInternal:${rev}" cd $tmpExternal if [ $? != 0 ]; then echo "2: No such directory $tmpExternal" exit 1 fi # applying the patch to tmpExternal Repo hg import -m "$sumTmpExternal" ${exPatch} if [ $? != 0 ]; then echo "import of ${exPatch} was not successful" exit 1 fi cp "${src}/build.properties" "${tmpExternal}/work/core/build/build.properties" 2> /dev/null if [ $? != 0 ]; then echo "2: No such file or directory" exit 1 fi ###################### #Build the imported changeset ###################### cd ${tmpExternal}/work/core/build if [ $? != 0 ]; then echo "2: No such directory ${tmpExternal}/work/core/build" exit 1cd ../ fi # build log's name is created besed on the rev number and date dateLog="Rev${rev}(${buildDate})" $ANT -logfile $doc/build$dateLog.txt app.ear    #Check if the build was successfulInternal Repository, push it to the hgExtURL grep -w "BUILD SUCCESSFUL" $doc/build$dateLog.txt 2>/dev/null if [ $? -eq 0 ]; then echo "BUILD & TEST SUCCESSFUL - Revision $rev" >> $doc/$report.txt # if build, test and applying the patch was successful then push it echo "PATCH APPLIED SUCCESSFULY - Revision $rev" >> $doc/$report.txt hg push error=0 else # if build was not successful apply the created patch as a Broken changeset these changes will be pulled to the tmpExternal echo "BUILD FAILED - Revision $rev" >> $doc/$report.txt error=1 fi fidone  # Display the reportecho "========================================" >> $doc/$reportController.txt echo -e "\n" >> $doc/$report.txtcat $doc/$report.txt  exit $error</source>
1
edit

Navigation menu