Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync Subversion and Harvest SCM repositories?

How would you integrate Subversion and CA Harvest SCM if using Subversion to sync work across a team and Harvest as the enterprise system of record?

An approach I'm investigating is creating a script that loads a SVN tag into Harvest, but am curious if anyone else has done something like this before or there is a better way to approach the problem.

like image 963
cwash Avatar asked Jun 08 '09 15:06

cwash


2 Answers

I ended up creating a script to synchronize Subversion to Harvest. We don't have to synchronize the other way around, but it wouldn't be hard to change the script to do that instead. You can check out the script here -> http://developerdad.com/2011/03/28/synchronize-subversion-to-ca-allfusion-harvest/

We’re using this script right now with our Jenkins (formerly Hudson) CI server so a new Harvest package is created (named by the %JOB_NAME% variable set by Jenkins) with each Production build is run.

Update

The website has been up and down, so here's the script:

@echo off

REM ###########################################################################
REM #
REM # Script file to move changes from Subversion to Harvest
REM #
REM ###########################################################################

if "%1" == "" goto usage

setlocal

set PROJECT_STAGE=-b "" -en "" -st ""
set VIEW=-vp ""
set CREDENTIALS=-usr "" -pw ""
set SUBVERSION_REPO=svn:////trunk/

REM Clean up any build artifacts if present
call ant clean

REM Create Harvest package
hcp %1 %PROJECT_STAGE% %CREDENTIALS%

REM Delete the checked-out Subversion code
REM Note: You will need to remove everything (except this file of course), so more rmdir or del statements may be required below
rmdir /S /Q project

REM Check out the files in Harvest to modify
hco * %PROJECT_STAGE% %CREDENTIALS% %VIEW% -p "%1" -pn "Check Out Files for Update" -up -r -s * -op pc -cp %CD%

REM Delete the checked-out Harvest code
REM Note: You will need to remove everything (except this file of course), so more rmdir or del statements may be required below
rmdir /S /Q project

REM Replace with the latest code from Subversion repository
svn co %SUBVERSION_REPO% .

REM Delete the .svn directories
for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (
  rd /s /q "%%i"
)

REM What are the updates for Harvest?  Check them into Harvest
hci * %PROJECT_STAGE% %CREDENTIALS% %VIEW% -p "%1" -pn "Check In Modified Files" -s * -ur -de "Added in Subversion" -if ne -op pc -cp %CD%

REM Remove the log files from Harvest
REM Note: You may need to change or remove this statement depending on whether you want the Harvest logs checked in
hdv *.log %PROJECT_STAGE% %CREDENTIALS% %VIEW% -pn "Delete Versions"

REM What removals from Harvest do we need to process? (What files were deleted in Subversion?)
hsv %PROJECT_STAGE% %CREDENTIALS% %VIEW% -p "%1" -it r -s "*"

REM This will not work if the file path has spaces in it.  You can use %%j %%k ... in the -vp switch for one space in your project name (For example, if you have 2 spaces, it should be -vp %%j %%k %%l)
for /f "tokens=1-5 skip=3" %%i in (hsv.log) do (
    if not "%%i"=="hsv" (
        hci "%%i" %PROJECT_STAGE% %CREDENTIALS% -vp "%%j" -p "%1" -pn "Check In Modified Files" -ro -cp %CD%
        hri "%%i" %PROJECT_STAGE% %CREDENTIALS% -vp "%%j" -p "%1"
    )
)

REM remove read-only attribute from all files
attrib -r -h * /s

REM delete all harvest.sig files
del /f /s /q harvest.sig

endlocal

goto end

:usage

echo USAGE:
echo -----------------------------------------------------------------------------
echo "svn2harvest {package_name}"
echo -----------------------------------------------------------------------------

:end
like image 170
jeffl8n Avatar answered Oct 03 '22 02:10

jeffl8n


I know that with subversion you can configure the server to run a script upon each commit, which might be able to call some functions on CA Harvest.

Another alternative if you are using Eclipse would be to integrate using Mylyn. Mylyn integrates with Subversion and I think there is an Eclipse plugin for CA Harvest - perhaps they will all work together nicely?

like image 30
Grouchal Avatar answered Oct 03 '22 01:10

Grouchal