Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all, all hooks are executed on the <strong>SERVER</strong> and not on the various client machines. Is that <code>C:\mypath\myworkingcopy</code> on the server? If not, it's not going to get updated.</p> <p>Second of all, it's bad form to do anything in a hook that might take too much time. If your hook needs something more than <code>svnlook</code>, chances are you're doing it wrong. For example, how long could it take to update that working copy? 10 seconds? 30 seconds? a minute? That's the added time a developer has to sit and wait for their Subversion commit to complete.</p> <p>It is much, much better to use something that can respond to commit events and have that do things like working copy updates or deployments to web servers outside of a post-commit hook. I highly recommend <a href="http://jenkins-ci.org">Jenkins</a> for this job. Jenkins has several nice features:</p> <ul> <li>It's cost effective (you can't beat free)</li> <li>It's well supported (post a question on Stackoverflow and get a quick response).</li> <li>It's a snap to setup and use.</li> </ul> <hr> <p>Now back to your question:</p> <p>First make sure the hook is running. Add to the bottom of the batch script this one line:</p> <pre><code> exit 2 </code></pre> <p>That will make Subversion think the post-commit hook has failed and you should get an error message on commit. If not, your post-commit script isn't running. Make sure the script is executable by the account that's running the Subversion server.</p> <p>If you do get an error message, the script is running. However, the svn command may not be returning an error that's getting picked up by the post-commit process. I normally don't recommend writing hooks in Windows batch programming language because of its limitations. Use Python or Perl or PowerShell. These are better at detecting error conditions and you can exit out of your script when detected.</p> <p>Then again, things are working perfectly, but you're looking at the wrong working copy (the one on your machine and not the one on the server). When you run hooks outside of the subversion server for testing, run them on the server as the Subversion user running the server process.</p> <p>Try these things and see if that corrects your problem.</p> <hr> <h2>Additional Comments</h2> <p>I created a repository with <code>svnadmin create</code> and ran it using <code>svnserve</code>. I updated <code>svnserve.conf</code> to allow me to checkout and commit code.</p> <p>I went into the <code>hooks</code> directory, renamed <code>pre-commit.tmpl</code> to <code>pre-commit.bat</code> and set it as:</p> <pre><code>set 1&gt;&amp;2 echo "Blocked my me!" 1&gt;&amp;2 exit 2 </code></pre> <p>When I attempted to commit my changes, I got:</p> <pre><code>Transmitting file data .svn: E165001: Commit failed (details follow): svn: E165001: Commit blocked by pre-commit hook (exit code 2) with output: [...] PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW PERL_JSON_BACKEND=JSON::XS PERL_YAML_BACKEND=YAML PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=2a07 [...] "Blocked my me!" </code></pre> <p>The hook is <strong><em>supposed to</em></strong> remove the environment (including the PATH), but I guess that's only on Unix and not Windows. You can see <code>PATHEXT</code> defined.</p> <p>I then renamed <code>pre-commit.bat</code> to <code>pre-commit.tmpl</code> and created a post-commit.bat` that looks like this:</p> <pre><code>echo This post-commit hook shall fail! 1&gt;&amp;2 exit 2 </code></pre> <p>During a commit, I got the following:</p> <pre><code>Transmitting file data . Committed revision 3. Warning: post-commit hook failed (exit code 2) with output: This post-commit shall fail! </code></pre> <p>It looks like everything is working as planned. I'm not using VisualSVN, and I'm not running as a service. I wonder if there might be an issue with your <code>PATHEXT</code> environment variable.</p> <p>Maybe take a look how it is set on your account that's running the Subversion server and see if <code>.BAT</code> is in there.</p> <p>I can't think of anything else right off hand.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload