Menu

SVN doesn't execute hook script

Help
Kevin Chu
2008-05-30
2013-05-01
  • Kevin Chu

    Kevin Chu - 2008-05-30

    Hello,

    I had TortoiseSVN 1.4.8, svn-win32-1.4.6, and SubversionNotify 1.4.5.3 installed on my server. And I wrote post-commit.bat which calls my-post-commit.vbs. These two files were stored in D:\SVN\SVNRepository\hooks.

    I tested these two script by running post-commit.bat under command line, and it worked successfully with an html format email sent out to my email account.  

    But when I test it after a commit on TortoiseSVN, no email was sent out. It looks like the hook script: post-commit.bat was never executed by Subversion after a commit since the SubversionNotify.log was never updated either. 

    What should I do to make it work?
    Please help. Thank you.

    Kevin chu

    Here are my files.
    ---------------------------------------------------------------------------------------

    <post-commit.bat>----------------------------------------------------------------------
    echo %1
    echo %2
    my-post-commit.vbs %1 %2

    <my-post-commit.vbs>----------------------------------------------------------------------
    Dim myPath
    Dim REPOSPATH, REVNUM

    Set objShell = CreateObject("WScript.Shell")
    Set objEnv = objShell.Environment("Process")
    objEnv("PATH") = "C:\Program Files\Subversion\bin\SubversionNotify;" & objEnv("PATH")
    'Wscript.Echo objEnv("PATH")

    'Create the object that is used to execute the command-line output.
    Set WshShell = Wscript.CreateObject("Wscript.Shell")

    If Wscript.Arguments.Count = 2 Then
      REPOSPATH = WScript.Arguments(0)
      REVNUM = WScript.Arguments(1)
      mypath = "%comspec% /c SubversionNotify " & REPOSPATH & " " & REVNUM & " -post"
      'Wscript.Echo mypath
      'Wscript.Echo objEnv("PATH")
      WshShell.Run(mypath), 0, true
    Else
      Wscript.Echo "post-commit.vbs usage: post-commit REPOS-PATH REV-NUM"
    End If

    <SubversionNotify.xml>---------------------------------------------------------------------
    <?xml version="1.0" standalone="yes"?>
    <subversionNotifyConfig xmlns="http://www.mckechney.com/SubversionNotifyConfig.xsd" LoggingLevel="DEBUG">
        <SVNConfig ExePath="C:\Program Files\Subversion\bin\svnlook.exe" />
       
        <MailServer Name="twgtpetc02ms009"
                    Username=""
                    Password=""
                    EMailSubjectTag="[SVN]"
                    FromAddress="default@mail.com"/>
       
        <ReproPathConfig ControlledPaths="/" ControlledRepros="" >
            <MailTo EMailAddress="kenneth.chu@nxp.com" EMailGroupName="" EMailType="HTML" EMailSuppressionChar="~" CustomSubjectFormat="#user# - #fileNames#"/>

            <!--<Execute Application="notepad.exe"/>-->

            <DefaultLogMessage Text="#user# has decided not to add a log message. Don't worry, severe punishment will be administered in short order."/>
           
            <CommitRequirements FailureMessage="Please add a commit message">
                  <CommitRequirement Description="Merge" Regex="\[merge\]"  SecondaryRegex="(http://|svn://|https://).+r\d+.to.r\d+" SecondaryRegexFailureMsg="A merge requires both the source path and revision numbers specified\n(ex: /[merge/] Merging http://myserver.com/repro/branch from r30 to r31)"/>

                  <!--<FolderNameExclusion  FolderName="Process" FolderNameRegex="\w"  FailureMessage="Failed on AddDelete" ControlledActionType="AddDelete"/> -->
               
                  <FileTypeTagCheck FileExtension=".resx~" FailureMessage="Failed on .txt AddDelete tag regex" ControlledActionType="All"/>
               
                  <FileTypeExclusion FileNameRegex=".resx~" FailureMessage="Failed on AddDelete file type exclusion" ControlledActionType="All"/>
            </CommitRequirements>

            <!--<CommitterExclusions>
                <CommitterExclude SvnID="mmckechn" CommitterExclusionType="ProcessExecution"/>
            </CommitterExclusions>-->

            <ItemTrackers>
                <!--<Bugzilla XmlReturnURL="http://mydomain.com/bugzilla/show_bug.cgi?id={0}&amp;ctype=xml"
                            BugLinkURL="http://mydomain.com/bugzilla/show_bug.cgi?id={0}"
                            BugRegex="\[b?u?g? ?#?([0-9]+(?:\s*,?\s*[0-9]+)*)\]">
                   
                    <AllowedProducts>
                        <AllowedProduct Name="ProductOne"/>
                    </AllowedProducts>
                   
                    <DisallowedStatuses>
                        <DisallowedStatus Name="CLOSED" ReproPathException="Test"/>
                        <DisallowedStatus Name="RESOLVED" ReproPathException=""/>
                    </DisallowedStatuses>
                   
                    <LockedBugs>
                        <Bug BugId="1000"/>
                        <Bug BugId="1002"/>
                        <Bug BugId="1002"/>
                    </LockedBugs>
                </Bugzilla>-->
            </ItemTrackers>
        </ReproPathConfig>

        <!--<LockedPaths>
            <LockedPath ReproPath="/MMS" />
        </LockedPaths>-->

        <PrePropChangeRequirements FailureMessage="A revision comment may only be changed if it includes a Change Request number. Please add [CR ###] to the changed message.">
            <PrePropChangeRequirement Description="Bug Number" Regex="\[c?r? ?#?([0-9]+(?:\s*,?\s*[0-9]+)*)\]" IsBugMatch="true"/>
        </PrePropChangeRequirements>

        <!--<EMailGroup Name ="group1">
            <Email Address="developer1@mail.com" DisplayName="Mike"/>
            <Email Address="worker2@mail.com" DisplayName="John"/>
        </EMailGroup>-->
    </subversionNotifyConfig>

     
    • Steve Williams

      Steve Williams - 2008-05-30

      You are making the single most common mistake for hooks.  Subversion runs the hook with no environment.  No PATH, no environment variables, nothing.  Your VBS script is assuming those environment variables such as PATH and COMSPEC exist, which is why it works perfectly from the command-line, but not from Subversion.

      Also, why do you execute a VBS script from the batch file just to execute Subversion Notify?  Why not use the batch files that come with Subversion Notify that call Subversion Notify straight from the batch file?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.