1

I am looking to automate a manual copy paste activity using SVN, Jenkins and Urban Code Deploy.

We have now created a SVN repo to have the same directory structure of the Unix server Dir structure. The challenge is, I cannot do a clean deploy as I only have to pick file which is changed in any of the folder and place it in the respective folder on the Unix server.

I am not able to figure out how to create a Jenkins job to pick files from multiple folders and create one package and deploy using Urban Code Deploy to multiple folders on the destination server.

a   
|------b
|   --------b
c
|-------d
    --------v
        --------m

This is just an illustration of the folder structure, in SVN and Unix server. Any help is appreciated

1
  • Thank you @nvoigt for the edit. I will keep the formatting and typo in mind next time. Commented Jul 31, 2017 at 15:46

2 Answers 2

0

You can pick only the modified files for a particular revision using the following commands and check them out to their respective directories in your Unix server:

svn checkout https://org.svn.host/path/to/your/file /path/to/target_dir --depth empty --revision <revisionNumber>

cd /path/to/target_dir

svn up file_you_want

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, I was looking from the perspective of picking files from multiple folders at the same time and creating a build which when exploded on the target server will put the files in the respect directories. If you have any suggestions please feel free to comment.
If you want to copy files from multiple folders at once to the multiple folders at the destination, then you should run multiple svn up commands simultaneously. If you are on a Linux system then go through this thread to see how you can run multiple command at once: stackoverflow.com/questions/10909685/…
0

I have made one PowerShell Script to pick up files from multiple folders. I also do the same thing for some Jenkins projects. So I hope it will help you. Please free feel to ask any help to understand the below script and/or how to use this script.

Script :-

#################  USER INPUT STARTS #####################################################################################################
$TARGET=""                                    #Give target path where you want to get only changed files with folder structure#
$SRCFILE=""                                   #Source path, your SVN checkout#
$SVNURL=""                                    #Give Repository URL For eg. "svn://0.0.0.0/abc/trunk/def"
$FINDSTR=""                                   #Give Value For eg. "trunk/def/" 
$Daysback="-06"                               #Give number of days. For eg. give "-01" if you want to get changed files from last 1 Day#
#################  USER INPUT ENDS #####################################################################################################
$CurrentDate=Get-Date
$DatetoDelete=$CurrentDate.AddDays($Daysback)
$Daysback="1"
$CurrentDate=Get-Date
$CurrentDate=$CurrentDate.AddDays($Daysback)
$FROM1=$CurrentDate.Year
$FROM2=$CurrentDate.Month
$FROM3=$CurrentDate.Day
$TO1=$DatetoDelete.Year
$TO2=$DatetoDelete.Month
$TO3=$DatetoDelete.Day
[string]$FROM = (get-date).ToString("$FROM1-$FROM2-$FROM3");
[string]$TO = (get-date).ToString("$TO1-$TO2-$TO3");
[string]$DATE = "{$FROM}:{$TO}";
$DATE                           
$DIFFER=D:\Subversion\bin\svn diff "$SVNURL" --summarize -r $DATE      #Here you have to give absolute path of your "svn.exe"  

IF($DIFFER)
{
    IF($DIFFER.count -GT 1)
    {
        for($i=0; $i -le ($DIFFER.Count-1); $i++)
        {
            $SYS11=$DIFFER[$i]
            $APP11=($SYS11 -SPLIT ',*'+$FINDSTR)[1]
            $FILEDIR="$APP11"
            $FILE=Split-Path $APP11 -leaf 
            $EXTENSION=(Split-Path -Path $FILE -Leaf).Split(".")[1];
            IF($EXTENSION)
            {
                $FILEDIR =$FILEDIR -replace $FILE, ""
                $TARGETDIR="$TARGET\$FILEDIR"
                IF (!(Test-Path $TARGETDIR))
                {
                    New-Item $TARGETDIR -type Directory > $null 
                }
                $FROM="$SRCFILE\$APP11"
                $TARGETFILE="$TARGET\$APP11"
                IF(Test-Path $FROM)
                {
                    Copy-Item $FROM $TARGETFILE -force
                    ECHO "==============================================================================="
                    ECHO "$FROM"
                    ECHO "**************"
                    ECHO "$TARGETFILE"
                    ECHO "**************"
                    ECHO "NAME OF COPIED FILE  ::: $FILE"
                }
                ELSE
                {
                    ECHO "NOT FOUND $FROM"
                }
            }   
        }    
    }
    ELSE
    {
        $SYS11=$DIFFER
        $APP11=($SYS11 -SPLIT ',*'+$FINDSTR)[1]
        $FILEDIR="$APP11"
        $FILE=Split-Path $APP11 -leaf 
        $EXTENSION=(Split-Path -Path $FILE -Leaf).Split(".")[1];
        IF($EXTENSION)
        {
            $FILEDIR =$FILEDIR -replace $FILE, ""
            $TARGETDIR="$TARGET\$FILEDIR"
            IF (!(Test-Path $TARGETDIR))
            {
                New-Item $TARGETDIR -type Directory > $null 
            }
            $FROM="$SRCFILE\$APP11"
            $TARGETFILE="$TARGET\$APP11"

            IF(Test-Path $FROM)
            {
                Copy-Item $FROM $TARGETFILE -force
                ECHO "==============================================================================="
                ECHO "$FROM"
                ECHO "**************"
                ECHO "$TARGETFILE"
                ECHO "**************"
                ECHO "NAME OF COPIED FILE  ::: $FILE"
            }
            ELSE
            {
                ECHO "NOT FOUND $FROM"
            }
        }
    }
}
ELSE
{
    ECHO "NO CHANGE IN $SVNURL"
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.