@@ -139,6 +139,18 @@ function updateCodes()
139139{
140140 curDir=` pwd`
141141 branchName=$1
142+
143+ # Check branch change and remove cache if needed
144+ branchMarkerFile=" ${CTP_HOME} /.dailyqa/.current_branch"
145+ if [ -f " $branchMarkerFile " ]; then
146+ currentBranch=` cat $branchMarkerFile `
147+ if [ " $currentBranch " != " $branchName " ]; then
148+ localBranchName=` echo $branchName | sed ' s#/#_#g' `
149+ cacheFile=" ${CTP_HOME} /.dailyqa/cubrid-testtools_${localBranchName} _CTP.zip"
150+ [ -f " $cacheFile " ] && rm -f " $cacheFile " && echo " Branch changed: $currentBranch -> $branchName (cache removed)"
151+ fi
152+ fi
153+
142154 changedCount=` cd ${CTP_HOME} ; run_grepo_fetch -r cubrid-testtools -b " $branchName " -p " CTP" -e " conf" --check-only . | grep " fetch" | grep CHANGED | wc -l`
143155
144156 if [ " $changedCount " -gt " 0" ]
369381 then
370382 echo " Action: $x , ${q_exec[$count]} .sh, CONTINUE"
371383 # Update CTP if ENV_CTP_BRANCH_NAME is set in continue mode
384+ tempBranchContinue=" "
372385 if [ $withoutSync -ne 1 ]
373386 then
374387 source ${CTP_HOME} /common/sched/init.sh $ser_site
375388 if [ " $CTP_BRANCH_NAME " ] && [ " $CTP_BRANCH_NAME " != " $branchName " ]
376389 then
377390 echo " ENV_CTP_BRANCH_NAME detected: $CTP_BRANCH_NAME (updating from $branchName )"
378391 updateCodes $CTP_BRANCH_NAME
392+ tempBranchContinue=" $branchName "
379393 fi
380394 fi
381395 (cd ${CTP_HOME} ; export BUILD_IS_FROM_GIT=$isFromGit ; source ${CTP_HOME} /common/sched/init.sh $ser_site ; sh common/ext/${q_exec[$count]} .sh YES)
382396
383397 echo
384398 echo " End continue mode test!"
385399 consumerTimer ${existsMsgId} " stop"
400+
401+ # Restore original branch if temp branch was used
402+ [ -n " $tempBranchContinue " ] && updateCodes $tempBranchContinue
403+
386404 contimeENDTIME=` getTimeStamp`
387405 echo " END_CONTINUE_TIME:${contimeENDTIME} "
388406 echo ' ' > ${CTP_HOME} /common/sched/status/${x}
393411 hasTestBuild
394412
395413 # update client again if ENV_CTP_BRANCH_NAME is set in message
414+ tempBranch=" "
396415 if [ " $hasBuild " == " true" ] && [ $withoutSync -ne 1 ]
397416 then
398417 source ${CTP_HOME} /common/sched/init.sh $ser_site
399418 if [ " $CTP_BRANCH_NAME " ] && [ " $CTP_BRANCH_NAME " != " $branchName " ]
400419 then
401420 echo " ENV_CTP_BRANCH_NAME detected: $CTP_BRANCH_NAME (updating from $branchName )"
402421 updateCodes $CTP_BRANCH_NAME
422+ tempBranch=" $branchName "
403423 fi
404424 fi
405425
440460
441461 consumerTimer $msgId " stop"
442462
463+ # Restore original branch if temp branch was used
464+ [ -n " $tempBranch " ] && updateCodes $tempBranch
465+
443466 ENDTIME=` getTimeStamp`
444467 echo
445468 echo " Clean msg id from queue file"
0 commit comments